diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2020-04-28 12:34:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-28 18:34:05 +0200 |
| commit | cb2b4e3522cb7f426ba5ad3e68deb9e6ccc581ec (patch) | |
| tree | 2a2f38823c3c9f0b5439ce2aa7c9040299109292 /lib/stitch_plan | |
| parent | eb526927e16954390d06929535d6f5c3766b5f6c (diff) | |
electron simulator (#531)
Diffstat (limited to 'lib/stitch_plan')
| -rw-r--r-- | lib/stitch_plan/stitch.py | 3 | ||||
| -rw-r--r-- | lib/stitch_plan/stitch_plan.py | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/stitch_plan/stitch.py b/lib/stitch_plan/stitch.py index 462634cb..ccbea12e 100644 --- a/lib/stitch_plan/stitch.py +++ b/lib/stitch_plan/stitch.py @@ -31,3 +31,6 @@ class Stitch(Point): def copy(self): return Stitch(self.x, self.y, self.color, self.jump, self.stop, self.trim, self.color_change, self.no_ties) + + def __json__(self): + return vars(self) diff --git a/lib/stitch_plan/stitch_plan.py b/lib/stitch_plan/stitch_plan.py index ac6b3b8d..0b2f75cd 100644 --- a/lib/stitch_plan/stitch_plan.py +++ b/lib/stitch_plan/stitch_plan.py @@ -98,6 +98,14 @@ class StitchPlan(object): def __repr__(self): return "StitchPlan(%s)" % ", ".join(repr(cb) for cb in self.color_blocks) + def __json__(self): + return dict(color_blocks=self.color_blocks, + num_stops=self.num_stops, + num_trims=self.num_trims, + num_stitches=self.num_stitches, + bounding_box=self.bounding_box + ) + @property def num_colors(self): """Number of unique colors in the stitch plan.""" @@ -175,6 +183,9 @@ class ColorBlock(object): def __delitem__(self, item): del self.stitches[item] + def __json__(self): + return dict(color=self.color, stitches=self.stitches) + def has_color(self): return self._color is not None |
