API Reference#

Main functionality#

class turtlethread.Turtle(pattern=None, angle_mode='degrees', scale=1)[source]#

Turtle object that to make embroidery files. Mirrored after the official turtle library.

Any undocumented functions have the same interface as the official turtle library.

One turtle-step is equivalent to 0.1 mm.

Parameters
patternpyembroidery.EmbPattern (optional)

The embroidery pattern to work with. If not supplied, then an empty pattern will be created.

angle_mode“degrees” or “radians” (optional, default=”degrees”)

How angles are computed.

scalefloat (optional, default=1)

Scaling between turtle steps and units in the embroidery file. Below are some example scaling

  • scale=1 - One step is one unit in the embroidery file (0.1 mm)

  • scale=10 - One step equals 1 mm

  • scale=2 - The scaling TurtleStitch uses

Attributes
angle
angle_mode

The angle mode, either “degrees” or “radians”.

Methods

back(distance)

Move backward a set distance, see the official documentation.

backward(distance)

Move backward a set distance, see the official documentation.

bk(distance)

Move backward a set distance, see the official documentation.

circle(radius[, extent, steps])

Draw a circle, see the official documentation.

cleanup_stitch_type()

Cleanup after switching to running stitch.

fd(distance)

Move forward a set distance, see the official documentation.

forward(distance)

Move forward a set distance, see the official documentation.

goto(x, y)

Goto a given position, see the official documentation.

heading()

Returns the turtle's heading (i.e.

home()

Move the needle home (position (0, 0)), see the official documentation.

jump_stitch()

Set the stitch mode to jump-stitch and cleanup afterwards.

left(angle)

Rotate left the specified angle, see the official documentation.

lt(angle)

Rotate left the specified angle, see the official documentation.

pos()

Get the position, see the official documentation.

position()

Get the position, see the official documentation.

right(angle)

Rotate right the specified angle, see the official documentation.

rt(angle)

Rotate right the specified angle, see the official documentation.

running_stitch(stitch_length)

Set the stitch mode to running stitch and cleanup afterwards.

save(filename)

Save the embroidery pattern as an embroidery or image file.

seth(angle)

Set the turtle's heading, 0 degrees is pointing right.

setheading(angle)

Set the turtle's heading, 0 degrees is pointing right.

setpos(x, y)

Goto a given position, see the official documentation.

setposition(x, y)

Goto a given position, see the official documentation.

show_info()

Display information about this turtle's embroidery pattern.

start_jump_stitch()

Set the stitch mode to jump-stitch (not recommended, use jump_stitch-context instead).

start_running_stitch(stitch_length)

Set the stitch mode to running stitch (not recommended, use running_stitch-context instead).

visualise([turtle, width, height, scale, ...])

Use the builtin turtle library to visualise this turtle's embroidery pattern.

property angle_mode#

The angle mode, either “degrees” or “radians”.

back(distance)#

Move backward a set distance, see the official documentation.

backward(distance)[source]#

Move backward a set distance, see the official documentation.

bk(distance)#

Move backward a set distance, see the official documentation.

circle(radius, extent=None, steps=None)[source]#

Draw a circle, see the official documentation.

cleanup_stitch_type()[source]#

Cleanup after switching to running stitch.

fd(distance)#

Move forward a set distance, see the official documentation.

forward(distance)[source]#

Move forward a set distance, see the official documentation.

goto(x, y)[source]#

Goto a given position, see the official documentation.

heading()[source]#

Returns the turtle’s heading (i.e. angle)

writing turtle.heading() gives the same result as writing turtle.angle.

home()[source]#

Move the needle home (position (0, 0)), see the official documentation.

jump_stitch()[source]#

Set the stitch mode to jump-stitch and cleanup afterwards.

With a jump-stitch, trim the thread and move the needle without sewing more stitches.

left(angle)[source]#

Rotate left the specified angle, see the official documentation.

lt(angle)#

Rotate left the specified angle, see the official documentation.

pos()#

Get the position, see the official documentation.

position()[source]#

Get the position, see the official documentation.

right(angle)[source]#

Rotate right the specified angle, see the official documentation.

rt(angle)#

Rotate right the specified angle, see the official documentation.

running_stitch(stitch_length)[source]#

Set the stitch mode to running stitch and cleanup afterwards.

With a running stitch, we get stitches with a constant distance between each stitch.

One step is equivalent to 0.1 mm, we recommend setting the minimum length between each stitch to 30 (3 mm).

Parameters
stitch_lengthint

Number of steps between each stitch.

save(filename)[source]#

Save the embroidery pattern as an embroidery or image file.

Saves the embroiery pattern to file. Supports standard embroidery file formats, such as .dst, .jef and .pes, and utility formats such as .png, .svg and .txt. For a full list of supported file formats, see the pyembroidery documentation.

Parameters
filenamestr
seth(angle)#

Set the turtle’s heading, 0 degrees is pointing right. See the official documentation.

setheading(angle)[source]#

Set the turtle’s heading, 0 degrees is pointing right. See the official documentation.

setpos(x, y)#

Goto a given position, see the official documentation.

setposition(x, y)#

Goto a given position, see the official documentation.

show_info()[source]#

Display information about this turtle’s embroidery pattern.

start_jump_stitch()[source]#

Set the stitch mode to jump-stitch (not recommended, use jump_stitch-context instead).

With a jump-stitch, trim the thread and move the needle without sewing more stitches.

start_running_stitch(stitch_length)[source]#

Set the stitch mode to running stitch (not recommended, use running_stitch-context instead).

With a running stitch, we get stitches with a constant distance between each stitch.

One step is equivalent to 0.1 mm, we recommend setting the minimum length between each stitch to 30 (3 mm).

It is recommended to use the running_stitch-context instead of the start-functions since they will automatically cleanup afterwards.

Parameters
stitch_lengthint

Number of steps between each stitch.

visualise(turtle=None, width=800, height=800, scale=1, done=True, bye=True)[source]#

Use the builtin turtle library to visualise this turtle’s embroidery pattern.

Parameters
patternpyembroidery.EmbPattern

Embroidery pattern to visualise

turtleturtle.Turtle (optional)

Python turtle object to use for drawing. If not specified, then the default turtle is used.

widthint

Canvas width

heightint

Canvas height

scaleint

Factor the embroidery length’s are scaled by.

donebool

If True, then turtle.done() will be called after drawing.

byebool

If True, then turtle.bye() will be called after drawing.

Additional utilities#

turtlethread.visualise.visualise_pattern(pattern, turtle=None, width=800, height=800, scale=1, done=True, bye=True)[source]#

Use the builtin turtle library to visualise an embroidery pattern.

Parameters
patternpyembroidery.EmbPattern

Embroidery pattern to visualise

turtleturtle.Turtle (optional)

Python turtle object to use for drawing. If not specified, then the default turtle is used.

widthint

Canvas width

heightint

Canvas height

scaleint

Factor the embroidery length’s are scaled by.

donebool

If True, then turtle.done() will be called after drawing.

byebool

If True, then turtle.bye() will be called after drawing.