diff options
Diffstat (limited to 'embroider_simulate.py')
| -rw-r--r-- | embroider_simulate.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/embroider_simulate.py b/embroider_simulate.py index 2d913bbb..6fdff57c 100644 --- a/embroider_simulate.py +++ b/embroider_simulate.py @@ -14,6 +14,7 @@ class EmbroiderySimulator(wx.Frame): self.on_close_hook = kwargs.pop('on_close', None) self.frame_period = kwargs.pop('frame_period', 80) self.stitches_per_frame = kwargs.pop('stitches_per_frame', 1) + self.target_duration = kwargs.pop('target_duration', None) wx.Frame.__init__(self, *args, **kwargs) @@ -22,6 +23,9 @@ class EmbroiderySimulator(wx.Frame): self.load(stitch_file, patches) + if self.target_duration: + self.adjust_speed(self.target_duration) + self.buffer = wx.Bitmap(self.width, self.height) self.dc = wx.MemoryDC() self.dc.SelectObject(self.buffer) @@ -51,6 +55,14 @@ class EmbroiderySimulator(wx.Frame): self.width, self.height = self.get_dimensions() + def adjust_speed(self, duration): + self.frame_period = 1000 * float(duration) / len(self.segments) + self.stitches_per_frame = 1 + + while self.frame_period < 1.0: + self.frame_period *= 2 + self.stitches_per_frame *= 2 + def on_key_down(self, event): keycode = event.GetKeyCode() |
