def main(): t0 = 0 t1 = pi * 24 n = 100000 path = [butterfly(t) for t in times(t0, t1, n)] drawing = xy.Drawing([path]).scale_to_fit(315, 380) xy.draw(drawing)
def main(): t = xy.Turtle(start_up=True) num_x = 10 num_y = 10 step_y = 10 step_x = 10 offset = [1 for _ in range(num_y)] wiggle = [1 for _ in range(num_y)] for ix in range(0, num_x): for iy in range(0, num_y): y = iy * step_y x = ix * step_x t.goto(x + offset[iy] - 1, y) square(t, 10, wiggle[iy] - 1) offset[iy] *= (1 + random.random() * 0.8) wiggle[iy] *= (1 + random.random()) drawing = t.drawing.origin().scale_to_fit(240, 165).center() drawing.render().write_to_png('out.png') xy.draw(drawing, verbose=False)
def main(): paths = create_paths() drawing = xy.Drawing(paths).origin().scale_to_fit(240, 165).center() drawing = drawing.sort_paths() im = drawing.render() im.write_to_png('eyes.png') xy.draw(drawing)
def main(): font = Font(xy.SCRIPTS, 600) d = font.wrap(TEXT, 115, 1, justify=True) d = d.center(130, 120) d = d.join_paths(tolerance=0.1).simplify_paths(tolerance=0.1) d.render(bounds=xy.A4_BOUNDS).write_to_png('out.png') xy.draw(d)
def main(): points = [(0, 0)] + hexagon() corners = [ (2, 1, 6), (1, 2, 0), (2, 0, 6), (0, 6, 1), (0, 2, 3), (2, 3, 4), (3, 4, 0), (4, 0, 2), (4, 0, 6), (0, 6, 5), (6, 5, 4), (5, 4, 0), ] paths = [] for a, b, c in corners: p1 = points[a] p2 = points[b] p3 = points[b] p4 = points[c] paths.extend(lines(p1, p2, p3, p4, 32)) drawing = xy.Drawing(paths).scale_to_fit(315, 380) drawing = drawing.sort_paths() drawing.render().write_to_png('lines.png') xy.draw(drawing)
def main(): paths = [] for path in PATHS: paths.extend(xy.parse_svg_path(path)) drawing = xy.Drawing(paths).scale(1, -1).scale_to_fit(9 * 25.4, 12 * 25.4) im = drawing.render() im.write_to_png('svg.png') xy.draw(drawing)
def main(): h = 128 for rule in [30]:#range(256): print rule drawing = create_drawing(rule, h) im = drawing.render()#line_width=1.25) im.write_to_png('rule%03d.png' % rule) drawing = drawing.sort_paths_greedy() xy.draw(drawing)
def main(iteration): t = xy.Turtle() for i in range(1, 2 ** iteration): t.forward(1) if (((i & -i) << 1) & i) != 0: t.circle(-1, 90, 36) else: t.circle(1, 90, 36) drawing = t.drawing.rotate_and_scale_to_fit(315, 380, step=90).scale(1, -1).origin() drawing.render().write_to_png('dragon.png') xy.draw(drawing)
def main(filename): paths = load_paths(filename) paths = xy.remove_duplicates(paths) drawing = xy.Drawing(paths).rotate_and_scale_to_fit(315, 380, step=90) # drawing = drawing.move(315 / 2.0, 380 / 2.0, 0.5, 0.5) drawing.paths = [x for x in drawing.paths if len(x) > 1] # drawing = drawing.simplify_paths() drawing = drawing.sort_paths_greedy() drawing = drawing.join_paths() # drawing = drawing.simplify_paths() im = drawing.render() im.write_to_png('paths.png') xy.draw(drawing)
x = new_lo + p * (new_hi - new_lo) result.append(x) return result random.seed(13) N = 400 noises = [random.random() * 2 - 1 for _ in range(N)] for _ in range(3): noises = low_pass(noises, 0.2) noises = normalize(noises, -1, 1) paths = [] x = 0 y = 0 m = 0.5 for i, n in enumerate(noises): r = i + 1 #N - i paths.append(xy.circle(x, y, r, 120)) a = n * math.pi x += math.cos(a) * m y += math.sin(a) * m drawing = xy.Drawing(paths) width = 250 height = 175 drawing = drawing.crop_paths(-width/2, -height/2, width/2, height/2).center(width, height) drawing.render().write_to_png('contain.png') xy.draw(drawing)