summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embroider_params.py2
-rw-r--r--embroider_simulate.py12
2 files changed, 13 insertions, 1 deletions
diff --git a/embroider_params.py b/embroider_params.py
index 1be10881..8300cbc2 100644
--- a/embroider_params.py
+++ b/embroider_params.py
@@ -401,7 +401,7 @@ class SettingsFrame(wx.Frame):
simulator_pos.x += 5
try:
- self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator", simulator_pos, size=(300, 300), patches=patches, on_close=self.simulate_window_closed, stitches_per_frame=10)
+ self.simulate_window = EmbroiderySimulator(None, -1, "Embroidery Simulator", simulator_pos, size=(300, 300), patches=patches, on_close=self.simulate_window_closed, target_duration=5)
except:
with open('/tmp/params_debug.log', 'a') as log:
print >> log, traceback.format_exc()
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()