示例#1
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))
示例#2
0
def loop(t):
    global leaves
    leaves=[]
    seed(t)
    with Move(0,-5),Scale((0.7,0.7)):
        tree(40,3*sin(2*t*pi),1)
        for l in leaves:
            circle(tuple(l),0.5)
        fill(HSVA(0,0,0))
示例#3
0
def loop(t):
    with Move(0, -5.5), Scale((2, 2)):
        global k, r, leaves
        leaves = []

        seed(6736)
        tree(7, 5 * sin(t * 5))
        for l in leaves:
            circle(tuple(l), 0.1 * t / 6)
        fill(HSVA(0, 0, 0))
示例#4
0
def loop(t):
    im = imi.copy()

    print(im, im.surf.get_data())
    with RedirectDrawingTo(im):
        circle((t * 5, 0), 30)
        fill()

    print(im, im.surf.get_data())
    ip = ImagePattern(im, pixels_per_unit=40)
    paint(ip, alpha=1)
示例#5
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))
示例#6
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()
示例#7
0
def loop_function(t):
    for i in range(36):
        with Rotate(i * 10):
            with Move(-(i % 6) * sin(t), 0):
                circle((5, 0), 0.5)
                fill(HSVA(i / 36 + t))
示例#8
0
def loop(t):
    if t < 1:
        print(1)
        print('Lets draw some circles.')
        for x in range(-2, 3):
            for y in range(-2, 3):
                circle((x, y), 0.5)
                fill()
        print('They are green by default.')

    if 1 <= t < 2:
        print(2)
        print('We can use a different color')
        for x in range(-2, 3):
            for y in range(-2, 3):
                circle((x, y), 0.5)
                fill(RGBA(1, 0, 0))
    if 2 <= t < 3:
        print(3)
        print('We can also use an image.')
        for x in range(-2, 3):
            for y in range(-2, 3):
                circle((x, y), 0.5)
                fill(ImagePattern(imag, pixels_per_unit=40))
    if 3 <= t < 4:
        print(4)
        print('We can display the full image with paint function')
        paint(ImagePattern(imag, pixels_per_unit=40))
        print('Colors are also patterns and can be painted.')
        print('Lets paint everything over with a red tone.')
        paint(RGBA(1, 0, 0, 0.2))
    if 4 <= t < 5:
        print(5)
        print('Lets apply a transformation to our drawing')
        with Rotate(45):
            for x in range(-2, 3):
                for y in range(-2, 3):
                    circle((x, y), 0.5)
                    fill(ImagePattern(imag, pixels_per_unit=40))
            print('Everything inside Rotate block is rotated by 45 degrees.')
    if 5 <= t < 6:
        print(6)
        print('But we can rotate only our ImagePattern.')
        with Rotate(45):
            pattern = ImagePattern(imag, pixels_per_unit=40)
        for x in range(-2, 3):
            for y in range(-2, 3):
                circle((x, y), 0.5)
                fill(pattern)
    if 6 <= t < 7:
        print(7)
        print('Or only our circles.')

        pattern = ImagePattern(imag, pixels_per_unit=40)

        with Rotate(45):
            for x in range(-2, 3):
                for y in range(-2, 3):
                    circle((x, y), 0.5)
                    fill(pattern)
    if 7 <= t < 8:
        print(8)
        print('But we can also draw our circles with Move blocks')
        print('and use separate ImagePattern for each circle.')
        for x in range(-2, 3):
            for y in range(-2, 3):
                with Move(x, y):
                    circle((0, 0), 0.5)
                    fill(ImagePattern(imag, pixels_per_unit=40))

    if 8 <= t:
        print('9')
        print('This property is truly fascinating.')
        with Rotate((t - 8) * 360):
            with Move(-2, -1.5):
                pattern = ImagePattern(imag, pixels_per_unit=40)

        with Move(t - 8, 0):
            for x in range(-2, 3):
                for y in range(-2, 3):
                    circle((x / 1.5, y / 1.5), 0.3)
                    fill(pattern)