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))
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))
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))
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)
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)
def ring(pattern): r=10 if new: for x in range(r): for y in range(r): with Move(x*0.5,y*0.5): #circle((0,0),0.15) rect((0,0),(0.3,0.3)) fill(pattern) else: for x in range(r): for y in range(r): with Move(x*0.5,y*0.5): rect((0,0),(0.3,0.3),pattern)
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))
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)
def loop(t): paint(RGBA(0, 0, 0)) g = LinearGradient((0, -2), (0, 2), [(0, RGBA(1, 0, 0)), (1, (RGBA(0, 0, 1)))]) if t > 9: g = RGBA(1, 1, 1, abs(9.2 - t) * 10) if t > 9.2: explain() t = 9.2 random.seed(t) text((-5.8, -1), 'Wisualia', 3) (a, b), (c, d) = fill_extents() buf = [] nr = int(t * 150) for _ in range(nr): x = random.uniform(a, c) y = random.uniform(b, d) if in_fill(x, y): buf.append((x, y)) fill(RGBA(0, 0, 0, 0)) draw_buf(buf, g) print('Wisualia, t=' + str(t))
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))
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)