Skip to content

Instantly share code, notes, and snippets.

@jacobian
Last active July 15, 2019 18:50
Show Gist options
  • Select an option

  • Save jacobian/5b0d04d0a58a6b236e3fa172a969fac5 to your computer and use it in GitHub Desktop.

Select an option

Save jacobian/5b0d04d0a58a6b236e3fa172a969fac5 to your computer and use it in GitHub Desktop.

Revisions

  1. jacobian revised this gist Jul 15, 2019. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions stitch.py
    Original file line number Diff line number Diff line change
    @@ -24,9 +24,7 @@
    # / \
    # 3 -- 2 remember: +x is to the right, +y is down

    pattern.move_abs(
    x * SIZE, y * SIZE
    ) # <--- this sucks at the end of a row, generates a huge jump :(
    pattern.move_abs(x * SIZE, y * SIZE) # <--- this sucks at the end of a row, generates a huge jump :(
    pattern.stitch(SIZE, SIZE)
    pattern.move(-SIZE, 0)
    pattern.stitch(SIZE, -SIZE)
  2. jacobian created this gist Jul 15, 2019.
    43 changes: 43 additions & 0 deletions stitch.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    import pyembroidery as em

    pattern = em.EmbPattern()

    # units are in 1/10mm
    # max size in DST is 12mm so if we go bigger need to fuck with max_stitch
    SIZE = 32

    # start with a stitch at the origin to get the needle down (see the docs)
    pattern.stitch_abs(0, 0)

    # stitch a 10x10 block
    # do y first so we stitch across then down
    # this doesn't really matter though
    for y in range(5):
    for x in range(5):

    # A single stitch:
    #
    # 1 4 1. jump to start of stitch (1)
    # \ / 2. 1. stitch diagonal down (1 -> 2)
    # \/ 3. jump back left (2 -> 3)
    # /\ 4. stitch diagonal up (3 -> 4) - next stitch starts here usually
    # / \
    # 3 -- 2 remember: +x is to the right, +y is down

    pattern.move_abs(
    x * SIZE, y * SIZE
    ) # <--- this sucks at the end of a row, generates a huge jump :(
    pattern.stitch(SIZE, SIZE)
    pattern.move(-SIZE, 0)
    pattern.stitch(SIZE, -SIZE)

    # XXX repeat a few times?
    # causes difficulty in stitch routing


    # tie off and cut (don't know if cut works)
    pattern.stitch(0, 0)
    pattern.trim()
    pattern.end()

    em.write_pes(pattern, "pattern.pes")