Exemplo n.º 1
0
def loop(t):
    #paint(RGBA(0,0,0))

    circle((0, 0), 1)
    circle((1, 0), 1)
    with Move(2, 1):
        p = Point(1, 1)
    a, b = p
    rect(p, p)
    print(p[0])
    print(p)
    with Clip():
        circle((0.5, 0), t)
        with Clip():

            #fill()
            paint(RGBA(1, 0, 0))

        #fill()
    #circle((0,1),1)
    #stroke()
    #with Move(2,0):
    ip = ImagePattern(image, 40)
    g = LinearGradient((0, 0), (3, 3), [(0, RGBA(1, 0, 0, 0)),
                                        (1, RGBA(1, 0, 0))])

    mask(ip, g)
    p = Pencil()
    p.line(1, 1)
    p.line(2, 1)
    p.draw()
    stroke()
Exemplo n.º 2
0
def tree(count,t,sf):
    if sf<0.1:
        leaves.append(Point(0,0))
        return
    line((0,0),(0,1))
    stroke(1,HSVA(0,0,0), cap=LineCap.ROUND)
    wind=t/sf/10
    if count%5!=3:
        with Move(0,1), Rotate(uniform(-20,20)+wind),Scale((0.93,0.93)):
            tree(count-1,t,sf*0.93)
        if random()<0.1:
            with Move(0,1), Rotate(uniform(-20,20)+wind),Scale((0.5,0.5)):
                tree(count//4,t,sf*0.5)
        return
    br=[]
    for i in range(choice([2,3,3,3,4])):
        d,s=cilrand(40)
        br.append((d,s))
    for d,s in br:
        d+=wind

        val=[0.6,0.5]
        shuffle(val)
        with Move(0,1), Rotate(d),Scale((0.9*s,0.95)):
            tree(count-1,t,sf*0.9)
Exemplo n.º 3
0
def loop(t):
    t = t + 0.1
    with Rotate(0 * 90):
        stops = [(0, RGBA(1, 0, 0, 0.3)), (1, RGBA(0, 0, 0.5, 0.3))]
        f = LinearGradient((0, 0), (5, 5), stops)
        f2 = RadialGradient((0, 0), 1, (5, 5), 10, stops)
    paint(f2, alpha=0.2)
    with Scale((1.5, 1)):
        circle((0, 0), 1)
        stroke(width=0.5)
        paint(ImagePattern(im, pixels_per_unit=40), alpha=0.7)

        p = Pencil()
        p.move(0, 3)
        p.line(0, 6)
        p.line(3, 6)
        p.line(3, 3)
        with Scale((1, 1)):
            p.arc((-1, -1), t * 30)

        p.draw()
        (a, b), (c, d) = fill_extents()

        for x in range(int(a), int(c)):
            for y in range(int(b), int(d)):
                if in_fill(x, y):
                    circle((x, y), 0.5)
                    print(x, y)
        rect((a, b), (c, d))
        fill(RGBA(0.2, 0, 0, 0.3))

        text((0, 0), 'Hell World.', 2)
        (a, b), (c, d) = fill_extents()
        rect((a, b), (c, d))
        fill(RGBA(0.2, 0, 0, 0.3))
Exemplo n.º 4
0
def draw_buf(buf, g):
    p = Pencil()
    for a in buf:
        for b in buf:
            if a != b and 0.2 < length(a, b) < 0.3:
                p.move(*a)
                p.line(*b)
    p.draw()
    stroke(width=0.03, pattern=g)
Exemplo n.º 5
0
def tree(count, t):
    if count == 0:
        leaves.append(Point(0, 0))
        return
    line((0, 0), (0, 1))
    stroke(0.2, HSVA(0, 0, 0))
    for d, w, n in [(-35, 0.4, 1), (0, 0.7, 1), (20, 0.5, 1)]:
        if True:
            d += t * 10 / count**2
        with Move(0, n), Rotate(d), Scale((w, 1.3 * w)):
            tree(count - 1, t)
Exemplo n.º 6
0
def explain():
    f = RGBA(0.2, 0.2, 0.2, 1)
    with Move(1, -2.5):
        text((0, 0), 'Python inside', 0.7)
        fill(f)
        p = Pencil()
        p.move(0, 0.1)
        p.line(5, 0.1)
        p.move(0, 0.27)
        p.line(5, 0.27)
        p.draw()
        stroke(pattern=RGBA(0, 0, 0), width=0.05)
Exemplo n.º 7
0
def loop(t):
    p1 = (0, 0)
    p2 = (0, 0)
    p3 = (-t, 3)
    p4 = (3, 3)

    p = Pencil()
    p.move(*p1)
    p.curve(p3, p3, p4)
    circle(p2, 0.1)
    circle(p3, 0.1)
    fill(RGBA(1, 0, 0))
    p.line(-5, -5)
    p.line(-6, -6)
    p.line(-3, 0)
    p.draw()
    stroke(0.1, RGBA(0, 1, 0))
Exemplo n.º 8
0
def loop(t):
    with  Scale((2.5,2.5)),Move(-4,-3):
        colors=[HSVA(0,0.4,0.7),HSVA(0.17,0.5,0.9),HSVA(0.17,0.5,0.56),HSVA(0.1,0.5)]
        if int(t)%2==0:
            colors=[HSVA(0,1,0.9),HSVA(0.17,1,0.9),HSVA(0.7,1,0.8),HSVA(0.1,1)]
        
        for d,c in zip(range(4),colors):
            ruudu(t,seitse,d)
            fill(c)

        ruudu(t,kaheksa)
        fill(HSVA(0,0.9,0.3))

        im=ImagePattern(image,300)
        paint(im,0.2)
        
        for d,c in zip(range(4),colors):
            ruudu(t,seitse,d)
        ruudu(t,kaheksa)
        
        n=0.56
        stroke(0.02,RGBA(n,n,n))
        paint(im,0.3)