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):
        t.forward(x / 4)
        t.left(math.pi / 6)
        t.forward(x / 4)
        t.left(5 * math.pi / 6)
        t.forward(x / 4)
        t.left(math.pi / 6)
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()
for l in range(30):
    ## Track progress
    vert_prop = l / 30

    ## Draw a seven-pointed star
    for k in range(7):
        ## Each line is slightly parabolically curved
        ## The bottom layer is completely flat, but
        ## subsequent layers are increasingly curved
        for x in range(-25, 26):
            horiz_prop = x / 25
            t.forward_lift(1, -vert_prop * horiz_prop * 0.3)
        t.right(6 * math.pi / 7)

    ## Move to the next layer
    t.lift(0.15)

t.penup()
for k in range(7):
    for x in range(-25, 26):
        horiz_prop = x / 25
        t.extrude(0.5)
        t.lift(2)
        t.extrude(-0.1)
        t.forward_lift(1, 4 - horiz_prop * 0.3)
        t.lift(-6)
    t.right(6 * math.pi / 7)

## Save to a GCODE file
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()
Example #5
0
    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()
hairs = HAIR_ROWS
t.forward(-HAIR_SPACE / 2)
t.left(math.pi / 2)
t.forward(HAIR_SPACE / 2)
while hairs > 0:
    for i in range(2):
        for r in range(hairs):
            t.forward(HAIR_SPACE)
            t.lift(-LIFT_DIST)
            t.extrude(EXTRUDE_AMT)  # 0.5
            t.penup()
            t.lift(2)
            t.extrude(-0.1)
            t.lift(LIFT_DIST - 2)
            ## t.pendown()
            t.dwell(100)  # 100
        t.left(math.pi / 2)
    hairs += -1
t.finish()