NUM_HAIRS = 200 LAYER_HEIGHT = 0.3 DIAMETER = 80 NUM_SIDES = 5 LAYERS = 200 dtheta = 2 * math.pi / NUM_HAIRS dx = DIAMETER * math.sin(dtheta / 2) t = ExtruderTurtle() ## Set up the turtle t.name("flex-circle.gcode") t.setup(x=100, y=100) t.rate(FEEDRATE) t.set_density(EXT_DENSITY) for l in range(LAYERS): for k in range(NUM_HAIRS): t.right(dtheta) t.forward(dx) t.left(HAIR_ANGLE) t.forward(HAIRLENGTH) t.dwell(50) t.forward(-2 * HAIRLENGTH) t.dwell(50) t.forward(HAIRLENGTH) t.right(HAIR_ANGLE) ## Move to the next layer t.lift(LAYER_HEIGHT)
from extruder_turtle import ExtruderTurtle import math ## Parameters for the spiral N = 40 ## Number of subdivisions of one round-trip radius = 20 ## Outer radius of the spiral dtheta = 2 * math.pi / N ## Change in heading after each step dx = radius * dtheta ## Forward movement during each step dr = -0.5 / N ## Change in radius with each step t = ExtruderTurtle() t.name("alien-tree.gcode") t.setup(x=100, y=100) t.set_density(0.07) # 0.05 t.rate(500) while radius > 0: t.forward(dx) t.right(dtheta) radius += dr dx = radius * dtheta for l in range(50): t.extrude(0.1) t.dwell(100) t.lift(0.05) # 0.1 for x in range(60): for l in range(10): t.extrude(0.1)
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("euler-spiral.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.5) length = 0 dl = 5 for i in range(200): length += dl t.move(dl) t.right(2 * math.pi * length * dl / 10) dl = 5 / length t.finish()
## Parameters for vase and rim oscillations N = 100 RADIUS = 20 PERIODS = 3 AMPLITUDE = 6 LAYERS = 200 dtheta = 2 * math.pi / N dx = RADIUS * dtheta radius = RADIUS t = ExtruderTurtle() ## Set up the turtle t.name("nonplanar-vase.gcode") t.setup(x=100, y=100) t.set_density(0.05) t.rate(500) ## Draw a spiral base dr = 0.5 / 60 base_rad = 0 base_dx = 0 while base_rad < RADIUS: t.forward(base_dx) t.right(2 * math.pi / 60) base_rad += dr base_dx = base_rad * 2 * math.pi / 60 ## First few layers "bulding up" the oscillations for l in range(20): prop = l / 20
## 2 is a primitive root modulo N DIAMETER = 50 dtheta = 2*math.pi/N dx = DIAMETER*math.sin(dtheta/2) n = 1 t = ExtruderTurtle() ## Set up the turtle t.name("not-a-cardioid.gcode") t.setup(x=100, y=100) t.rate(700) for l in range(50): ## Draw a circle t.set_density(0.07) t.left(dtheta/2) for k in range(N): t.right(dtheta) t.move(dx) t.right(dtheta/2) ## Draw several chords for i in range(10): t.dwell(100) t.set_density(0.03) angle = n*dtheta/2 t.right(angle) t.move(DIAMETER*math.sin(angle)) t.right(angle) ## Point n is joined by a line segment to point 2n
from extruder_turtle import ExtruderTurtle import math import random t = ExtruderTurtle() t.name("random-cone.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.02) for l in range(80 * 7): t.forward(20 - l * 20 / (80 * 7)) t.right(2 * math.pi / 7 + math.pi * random.random() / 500) t.lift(0.3 / 7) t.lift(1) t.extrude(0.8) t.lift(-1) t.dwell(200) t.finish()
from extruder_turtle import ExtruderTurtle import math ## Parameters for the spiral N = 40 ## Number of subdivisions of one round-trip radius = 20 ## Outer radius of the spiral dtheta = 2 * math.pi / N ## Change in heading after each step dx = radius * dtheta ## Forward movement during each step dr = -0.5 / N ## Change in radius with each step t = ExtruderTurtle() t.name("palm-tree.gcode") t.setup(x=100, y=100) t.set_density(0.06) # 0.05 t.rate(500) while radius > 0: t.forward(dx) t.right(dtheta) radius += dr dx = radius * dtheta for l in range(50): t.extrude(0.1) t.dwell(100) t.lift(0.1) # 0.1, 0.05 for x in range(60): prog = x / 60 frond_length = prog**4 * 20
from extruder_turtle import ExtruderTurtle import math import random t = ExtruderTurtle() t.name("random-hourglass.gcode") t.setup(x=100, y=100) t.rate(500) t.set_density(0.04) for l in range(240 * 7): t.forward(10 * math.sqrt(12 * (l / (240 * 7) - 1 / 2)**2 + 1)) t.right(2 * math.pi / 7 + math.pi * random.random() / 500) t.lift(0.2 / 7) t.lift(1) t.extrude(0.4) t.lift(-1) t.dwell(200) t.finish()
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() ## Set up the turtle t.name("tall-bumpy-star.gcode") t.setup(x=100, y=100) t.rate(1000) t.set_density(0.2) t.lift(2) for l in range(50): ## Draw a seven-pointed star for k in range(7): t.forward(50) t.right(6 * math.pi / 7) ## Move to the next layer t.lift(0.6) # 0.5 gets too squished # 1 gets too bumpy ## Save to a GCODE file t.finish()
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() ## Set up the turtle t.name("bumpy-star.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.3) t.lift(1) for l in range(9): # height of 10.5 ## Draw a seven-pointed star for k in range(7): t.forward(50) t.right(6 * math.pi / 7) ## Move to the next layer t.lift( 1.2 ) # 0.7 for first demo, 0.6 for second demo, 0.9 for third demo, 1.2 for fourth demo # 0.5 gets too squished # 1 gets too bumpy ## Save to a GCODE file t.finish()
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("square-string-art.gcode") t.setup(x=100, y=100) t.rate(500) t.set_density(0.06) for l in range(50): x = 5 * (l % 10) y = 5 * (l % 10) theta = math.atan(y / (50 - x)) r = math.sqrt((50 - x)**2 + y**2) for i in range(3): t.forward(50) t.left(math.pi / 2) t.forward(50) t.left(math.pi * 3 / 4) t.forward(50 * math.sqrt(2)) t.left(math.pi * 3 / 4) t.lift(0.3) t.lift(-0.2) t.set_density(0.03) t.forward(x) t.left(theta) t.forward(r) t.forward(-r) t.right(theta) t.forward(-x)