|
9 | 9 | from . import fills |
10 | 10 | from .base_turtle import TNavigator, Vec2D |
11 | 11 | from .pattern_info import show_info |
12 | | -from .visualise import visualise_pattern |
| 12 | +from .visualise import visualise_pattern, fast_visualise |
13 | 13 |
|
14 | 14 | USE_SPHINX_GALLERY = False |
15 | 15 |
|
@@ -182,7 +182,7 @@ def circle(self, radius, extent=None, steps=None): |
182 | 182 |
|
183 | 183 | super().circle(radius=radius, extent=extent, steps=steps) |
184 | 184 |
|
185 | | - def start_running_stitch(self, stitch_length): |
| 185 | + def start_running_stitch(self, stitch_length=30): |
186 | 186 | """Set the stitch mode to running stitch (not recommended, use ``running_stitch``-context instead). |
187 | 187 |
|
188 | 188 | With a running stitch, we get stitches with a constant distance between each stitch. |
@@ -290,6 +290,9 @@ def start_z_stitch( |
290 | 290 |
|
291 | 291 | def start_direct_stitch(self): |
292 | 292 | self.set_stitch_type(stitches.DirectStitch(self.pos())) |
| 293 | + |
| 294 | + def start_fast_direct_stitch(self): |
| 295 | + self.set_stitch_type(stitches.FastDirectStitch(self.pos())) |
293 | 296 |
|
294 | 297 | def cleanup_stitch_type(self): |
295 | 298 | """Cleanup after switching stitch type.""" |
@@ -331,7 +334,7 @@ def use_stitch_group(self, stitch_group): |
331 | 334 |
|
332 | 335 | self.cleanup_stitch_type() |
333 | 336 |
|
334 | | - def running_stitch(self, stitch_length): |
| 337 | + def running_stitch(self, stitch_length=30): |
335 | 338 | """Set the stitch mode to running stitch and cleanup afterwards. |
336 | 339 |
|
337 | 340 | With a running stitch, we get stitches with a constant distance between each stitch. |
@@ -444,6 +447,9 @@ def z_stitch( |
444 | 447 |
|
445 | 448 | def direct_stitch(self): |
446 | 449 | return self.use_stitch_group(stitches.DirectStitch(self.pos(), self.curr_color)) |
| 450 | + |
| 451 | + def fast_direct_stitch(self): |
| 452 | + return self.use_stitch_group(stitches.FastDirectStitch(self.pos(), self.curr_color)) |
447 | 453 |
|
448 | 454 | @property |
449 | 455 | def _position(self): |
@@ -523,6 +529,46 @@ def visualise(self, turtle=None, width=800, height=800, scale=1, speed=6, trace_ |
523 | 529 | print(e) |
524 | 530 | # Errors when you close the window! Yikes |
525 | 531 | pass |
| 532 | + |
| 533 | + def fast_visualise(self, turtle=None, width=800, height=800, scale=1, speed=6, trace_jump=False, skip=False, check_density=True, done=True, bye=True): |
| 534 | + """A fast version of the visualise() function, though it has undergone less testing. |
| 535 | +
|
| 536 | + Parameters |
| 537 | + ---------- |
| 538 | + pattern : pyembroidery.EmbPattern |
| 539 | + Embroidery pattern to visualise |
| 540 | + turtle : turtle.Turtle (optional) |
| 541 | + Python turtle object to use for drawing. If not specified, then the default turtle |
| 542 | + is used. |
| 543 | + width : int |
| 544 | + Canvas width |
| 545 | + height : int |
| 546 | + Canvas height |
| 547 | + scale : int |
| 548 | + Factor the embroidery length's are scaled by. |
| 549 | + speed : int |
| 550 | + Speed that the turtle object moves at. |
| 551 | + trace_jump : bool |
| 552 | + If True, then draw a grey line connecting the origin and destination of jumps. |
| 553 | + skip : bool |
| 554 | + If True, then skip the drawing animation and jump to the completed visualisation. |
| 555 | + check_density : bool |
| 556 | + If True, then check the density of the embroidery pattern. Recommended but slow. |
| 557 | + done : bool |
| 558 | + If True, then ``turtle.done()`` will be called after drawing. |
| 559 | + bye : bool |
| 560 | + If True, then ``turtle.bye()`` will be called after drawing. |
| 561 | + """ |
| 562 | + try: |
| 563 | + fast_visualise( |
| 564 | + self, |
| 565 | + turtle=turtle, width=width, height=height, scale=scale, speed=speed, trace_jump=trace_jump, skip=skip, |
| 566 | + check_density=check_density, done=done, bye=bye |
| 567 | + ) |
| 568 | + except Exception as e: |
| 569 | + print(e) |
| 570 | + # Errors when you close the window! Yikes |
| 571 | + pass |
526 | 572 |
|
527 | 573 | def show_info(self): |
528 | 574 | """Display information about this turtle's embroidery pattern.""" |
|
0 commit comments