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)
    for c in range(5):
        t.forward(70)
        t.right(math.pi / 2)
        t.forward(10)
        t.right(math.pi / 2)
        t.forward(70)
        t.left(math.pi / 2)
        t.forward(4)
        t.left(math.pi / 2)
    t.forward(70)
    t.left(math.pi / 2)
    t.forward(4)
    t.lift(0.2)

t.finish()
Пример #2
0
    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)
    t.left(math.pi / 2)
    radius_delta = RADIUS * math.sin(1.5 * math.pi *
                                     (total_prop + 1 / 3)) / (LAYERS / 2)
    t.forward(radius_delta)
    radius += radius_delta
    dx = radius * dtheta
    t.right(math.pi / 2)

## The rest of the layers, with full oscillations
for l in range(LAYERS - 20):
    total_prop = (l + 20) / LAYERS
    for k in range(N):
        angle = k * dtheta
        t.forward_lift(dx, PERIODS * AMPLITUDE * math.sin(PERIODS * angle) / N)
        t.right(dtheta)
Пример #3
0
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)
        t.lift(0.1)
    for n in range(5):
        t.forward(frond_length)
        t.left(math.pi / 6)
        t.forward(frond_length)
        t.left(5 * math.pi / 6)
        t.forward(frond_length)
        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()
Пример #5
0
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)
    t.set_density(0.06)
    t.pendown()

t.finish()
Пример #6
0
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)
            t.forward(50)
            t.pendown()
            t.rate(700)
            t.set_density(0.05)
            t.left(math.pi / 2)
            t.forward(1)
            t.lift(-10)
        t.forward(0.5)
    else:
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()
Пример #8
0
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()
Пример #9
0
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()

## 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()
Пример #11
0
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)
Пример #12
0
from extruder_turtle import ExtruderTurtle
import math

t = ExtruderTurtle()

## Set up turtle
t.name("nonplanar-star.gcode")
t.setup(x=100, y=100)
t.rate(500)

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)

## Save to a GCODE file
t.finish()
Пример #13
0
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()
hairs = HAIR_ROWS
t.forward(-HAIR_SPACE / 2)
t.left(math.pi / 2)
t.forward(HAIR_SPACE / 2)
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
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()
Пример #16
0
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)
t.pendown()

radius = RADIUS
dx = RADIUS * dtheta
while radius>0:
    t.forward(dx)
    t.right(dtheta)
    radius += dr
Пример #17
0
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

## Save to a GCODE file
t.finish()
Пример #18
0
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)
        t.forward(x / 4)
        t.left(math.pi / 6)
Пример #19
0
from extruder_turtle import ExtruderTurtle
import math

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