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 import random t = ExtruderTurtle() t.name("random-polygon.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.02) for l in range(60): for i in range(7): t.forward(20) 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()
sidelength = 50 t = ExtruderTurtle() t.name("evolving_snowflake.gcode") t.setup(x=100, y=100) t.rate(700) for g in range(NUM_GENS): for l in range(40): progress = l/40 gap_length = progress*sidelength/3 long_length = (sidelength - gap_length)/2 for r in instr: if r == "f": t.forward(long_length) t.left(math.pi/3) t.forward(gap_length) t.right(2*math.pi/3) t.forward(gap_length) t.left(math.pi/3) t.forward(long_length) elif r == "r": t.right(math.pi/3) elif r == "l": t.left(math.pi/3) t.lift(0.3) new_instr = "" for r in instr: new_instr += sub_rules[r] instr = new_instr
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) t.lift(0.2)
GENS = 5 sidelength = 50 / 2**GENS t = ExtruderTurtle() t.name("hilbert.gcode") t.setup(x=100, y=100) t.set_density(0.05) t.rate(800) for g in range(GENS): new_instr = "" for r in instr: new_instr += sub_rules[r] instr = new_instr for l in range(10): for r in instr: if r == "F": t.forward(sidelength) elif r == "+": t.right(math.pi / 2) elif r == "-": t.left(math.pi / 2) t.lift(0.3) for r in reversed(instr): if r == "F": t.backward(sidelength) elif r == "+": t.left(math.pi / 2) elif r == "-": t.right(math.pi / 2) t.lift(0.3) t.finish()
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) ## Save to a GCODE file t.finish()
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("complex-walk.gcode") t.setup(x=100, y=100) t.rate(700) N = 75 period = 224 angle = 2 * math.pi / N for l in range(30): for k in range(period + 1): t.forward(2) t.right(angle * k * (k - 1) / 2) t.lift(0.3) t.finish()
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()
t = ExtruderTurtle() ## Set up the turtle t.name("braille-ca.gcode") t.setup(x=100, y=100) t.rate(FEEDRATE) t.set_density(EXT_DENSITY) ca = [0] * NUM_SIDES ca[0] = 1 on_states = [1, 2, 3, 4] # Wolfram's "Rule 30" for l in range(LAYERS): for k in range(NUM_SIDES): t.right(dtheta) t.forward(dx) if ca[k] == 1: t.left(BUMP_ANGLE) t.forward(BUMPLENGTH) t.forward(-BUMPLENGTH) t.right(BUMP_ANGLE) t.lift(LAYER_HEIGHT / NUM_SIDES) ## Update cellular automaton if l % 3 == 2: new_ca = [0] * NUM_SIDES for i in range(NUM_SIDES): state_num = ca[(i - 1) % NUM_SIDES] * 4 + ca[i] * 2 + ca[(i + 1) % NUM_SIDES] if state_num in on_states: new_ca[i] = 1 ca = new_ca
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() t.name("stretchy-line.gcode") t.setup(x=100, y=100) t.rate(900) t.set_density(0.05) for l in range(10): t.forward(20) t.right(math.pi / 2) t.forward(5) t.left(math.pi / 2) t.forward(2) t.left(math.pi / 2) t.forward(10) t.right(math.pi / 2) t.forward(2) t.right(math.pi / 2) t.forward(5) t.left(math.pi / 2) t.forward(20) t.right(math.pi) t.lift(0.3) t.finish()
from extruder_turtle import ExtruderTurtle import math import random t = ExtruderTurtle() t.name("random-frustum.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 * 15 / (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 t = ExtruderTurtle() t.name("curly-line.gcode") t.setup(x=100, y=100) t.rate(700) t.set_density(0.2) t.lift(1) t.forward(100) t.left(math.pi / 2) t.penup() t.lift(10) t.forward(20) t.lift(-10) t.left(math.pi / 2) t.lift(1) t.pendown() t.forward(100) t.right(math.pi / 2) t.penup() t.lift(10) t.forward(20) t.lift(-10) t.right(math.pi / 2) t.lift(1) t.pendown() t.forward(100)
LIFT_DIST = 10 EXTRUDE_AMT = 0.5 t = ExtruderTurtle() t.name("hair-patch.gcode") t.setup(x=100, y=100) t.rate(1000) t.set_density(0.05) ## Draw the base for l in range(3): length = (HAIR_ROWS + 1) * HAIR_SPACE while length > 0: t.left(math.pi / 2) t.forward(length) t.left(math.pi / 2) t.forward(length) length += -0.7 t.lift(0.2) while length < (HAIR_ROWS + 1) * HAIR_SPACE: length += 0.7 t.backward(length) t.right(math.pi / 2) t.backward(length) t.right(math.pi / 2) t.lift(0.2) t.lift(LIFT_DIST + 0.2) t.set_density(0.01) t.penup()
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("stretchy-material.gcode") t.setup(x=100, y=100) t.rate(900) t.set_density(0.05) for l in range(5): for r in range(5): for n in range(4): t.forward(10) t.right(math.pi / 2) t.forward(4) t.left(math.pi / 2) t.forward(2) t.left(math.pi / 2) t.forward(8) t.right(math.pi / 2) t.forward(2) t.right(math.pi / 2) t.forward(4) t.left(math.pi / 2) sgn = (-1)**(r % 2) t.forward(10) t.left(math.pi / 2 * sgn) t.forward(14) t.left(math.pi / 2 * sgn) t.left(math.pi / 2)
from extruder_turtle import ExtruderTurtle import math t = ExtruderTurtle() t.name("horizontal-brush.gcode") t.setup(x=200, y=100) t.rate(700) t.set_density(0.05) for l in range(100): t.forward(5) t.right(math.pi / 2) t.forward(20) t.right(math.pi / 2) t.forward(5) t.right(math.pi / 2) if l % 5 == 3: t.forward(0.5) for i in range(19): t.left(math.pi / 2) t.rate(3000) t.set_density(0.02) t.forward(50) t.lift(0.2 - l * 0.2) t.penup() t.forward(10) t.lift(l * 0.2 - 0.2) t.forward(-10) t.lift(10) t.right(math.pi)
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 total_prop = l / LAYERS for k in range(N): angle = k * dtheta t.forward_lift( dx, PERIODS * AMPLITUDE * prop * math.sin(PERIODS * angle) / N) t.right(dtheta) t.lift(0.25 / N)
## 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 for l in range(10): t.extrude(0.1) t.dwell(100)
N = 40 ## Number of subdivisions of one round-trip RADIUS = 5 ## 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("hair-pillar.gcode") t.setup(x=150, y=150) t.set_density(0.07) # 0.05 t.rate(500) radius = RADIUS while radius>0: t.forward(dx) t.right(dtheta) radius += dr dx = radius * dtheta for l in range(200): t.extrude(0.1) t.dwell(200) t.lift(0.1) # 0.1 t.penup() t.forward(80) t.right(math.pi/2) t.forward(80) t.right(math.pi) t.lift(-20)
dx = DIAMETER*math.sin(dtheta/2) t = ExtruderTurtle() ## Set up the turtle t.name("dreamcatcher.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.forward(dx) t.right(dtheta/2) ## Draw a random chord on the circle t.dwell(100) t.set_density(0.03) rand_angle = dtheta*random.randint(1,N)/2 t.right(rand_angle) t.forward(DIAMETER*math.sin(rand_angle)) t.right(rand_angle) ## Move to the next layer t.lift(0.3) ## Save to a GCODE file t.finish()
## 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) t.dwell(100) t.lift(0.1) for n in range(5):
LENGTH = 20 PILLAR_ROWS = 8 t = ExtruderTurtle() ## Set up the turtle t.name("pillar-array.gcode") t.setup(x=100, y=100) t.lift(0.1) t.rate(700) t.set_density(0.05) num_zigzags = math.floor(LENGTH / 0.4) for i in range(num_zigzags): t.forward(LENGTH) t.right(math.pi / 2) t.forward(0.2) t.right(math.pi / 2) t.forward(LENGTH) t.left(math.pi / 2) t.forward(0.2) t.left(math.pi / 2) t.lift(0.1) pillar_space = LENGTH / PILLAR_ROWS t.penup() t.rate(1500) for i in range(PILLAR_ROWS): for j in range(PILLAR_ROWS): t.extrude(0.1)