Пример #1
0
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()
Пример #2
0
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
        n = (3*n) % N

    ## Move to the next layer
    t.lift(0.3)
NUM_SIDES = 5
LAYERS = 100

t = ExtruderTurtle()

## Set up the turtle
t.name("gappy-prism.gcode")
t.setup(x=100, y=100)
t.rate(700)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        ## Draw one side, with a randomly chosen gap
        x = (SIDELENGTH-GAPLENGTH) * random.random()
        t.move(x)
        ## Move out of the way in order to break the plastic strand
        t.penup()
        t.right(math.pi/2)
        t.move(SIDELENGTH)
        t.dwell(50)
        t.left(math.pi)
        t.move(SIDELENGTH)
        t.right(math.pi/2)
        ## Skip over the gap and continue drawing the side
        t.move(GAPLENGTH)
        t.pendown()
        t.move(SIDELENGTH-GAPLENGTH-x)
        t.right(2*math.pi/NUM_SIDES)

    ## Move to the next layer
SIDELENGTH = 25
NUM_SIDES = 5
LAYERS = 100
dx = SIDELENGTH/(NUM_HAIRS+1)

t = ExtruderTurtle()

## Set up the turtle
t.name("furry-prism.gcode")
t.setup(x=100, y=100)
t.rate(FEEDRATE)
t.set_density(EXT_DENSITY)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        t.move(dx)
        for n in range(NUM_HAIRS):
            t.left(HAIR_ANGLE)
            t.move(HAIRLENGTH)
            t.move(-HAIRLENGTH)
            t.right(HAIR_ANGLE)
            t.move(dx)
        t.right(2*math.pi/NUM_SIDES)

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

## Save to a GCODE file
t.finish()
Пример #5
0
from extruder_turtle import ExtruderTurtle
import math

t = ExtruderTurtle()

## Set up the turtle
t.name("feedrate-test.gcode")
t.setup(x=100, y=100)

## Parameters
min_rate = 200
max_rate = 10000
height = 200

for l in range(height):
    ## Feedrate increases linearly from one layer to the next,
    ## making the extruder move faster and faster
    t.rate(min_rate + l * (max_rate - min_rate) / height)

    ## Draw a square
    for k in range(4):
        t.move(30)
        t.right(math.pi / 2)

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

## Save to a GCODE file
t.finish()
LAYERS = 100

t = ExtruderTurtle()

## Set up the turtle
t.name("bumpy-prism.gcode")
t.setup(x=100, y=100)
t.rate(700)
t.set_density(0.07)

for l in range(LAYERS):
    ## Draw a pentagon
    for k in range(NUM_SIDES):
        ## Draw one side, with a randomly placed bump
        x = SIDELENGTH * random.random()
        t.move(x)
        t.left(BUMP_ANGLE)
        t.rate(100)
        t.move(BUMPLENGTH)
        t.dwell(50)
        t.move(-BUMPLENGTH)
        t.rate(700)
        t.right(BUMP_ANGLE)
        t.move(SIDELENGTH - x)
        t.right(2 * math.pi / NUM_SIDES)

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

## Save to a GCODE file
t.finish()