diff options
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 |
