summaryrefslogtreecommitdiff
path: root/lib/stitch_plan/stitch_plan.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitch_plan/stitch_plan.py')
-rw-r--r--lib/stitch_plan/stitch_plan.py11
1 files changed, 11 insertions, 0 deletions
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