Skip to content

Commit

Permalink
version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
tatarize committed May 20, 2022
1 parent 1a20ff5 commit 47a1a43
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="vpype-embroidery",
version="0.2.0",
version="0.3.0",
description="vpype embroidery plugin",
long_description=readme,
long_description_content_type="text/markdown",
Expand Down
6 changes: 4 additions & 2 deletions vpype_embroidery/eread.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import vpype_cli
from pyembroidery import EmbPattern

_EMB_SCALE_FACTOR = 2.645833333333333
_EMB_IN_MM = 0.1
_PX_IN_MM = 0.2645833333333333 # 1/96 inch
_EMB_PER_PX = _EMB_IN_MM / _PX_IN_MM


@click.command()
Expand All @@ -22,11 +24,11 @@ def eread(document: vp.Document, filename: str):
if len(stitches) == 0:
continue
lc = vp.LineCollection()
lc.scale(1.0 / _EMB_SCALE_FACTOR)
stitch_block = np.asarray(stitches, dtype="float")
stitch_block = stitch_block[..., 0] + 1j * stitch_block[..., 1]
lc.append(stitch_block)
lc.set_property(vp.METADATA_FIELD_COLOR, vp.Color(color.hex_color()))
lc.scale(_EMB_PER_PX)
document.add(lc, with_metadata=True)
return document

Expand Down
7 changes: 5 additions & 2 deletions vpype_embroidery/ewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import vpype_cli
from pyembroidery import COLOR_BREAK, SEQUENCE_BREAK, STITCH, EmbPattern

_EMB_SCALE_FACTOR = 2.645833333333333

_EMB_IN_MM = 0.1
_PX_IN_MM = 0.2645833333333333 # 1/96 inch
_PX_PER_EMB = _PX_IN_MM / _EMB_IN_MM


@click.command()
Expand All @@ -21,7 +24,7 @@ def ewrite(document: vp.Document, filename: str, version: str):
pattern = EmbPattern()
for layer in document.layers.values():
for p in layer:
m = p * _EMB_SCALE_FACTOR
m = p * _PX_PER_EMB
for v in m:
pattern.add_stitch_absolute(STITCH, int(v.real), int(v.imag))
pattern.add_command(SEQUENCE_BREAK)
Expand Down

0 comments on commit 47a1a43

Please sign in to comment.