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()
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): 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 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(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)