Skip to content

Commit cb40716

Browse files
committed
fix draw text newline and improve fast visualise
1 parent a38b967 commit cb40716

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/turtlethread/text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, fontpath, outfolder):
3030

3131

3232
class LetterDrawer():
33-
letter_gap = 0.03
33+
letter_gap = -0.1
3434
line_spacing = 1.15
3535

3636
def __init__(self, turtle, load_common_fonts:bool=False):
@@ -275,7 +275,7 @@ def draw_string(self, fontname, string, fontsize, colours='#000000', thicknesses
275275
if string[cidx] in ['\n', '\r']:
276276
# newline
277277
with turtle.jump_stitch():
278-
starty -= fontsize*LetterDrawer.line_spacing
278+
starty += fontsize*LetterDrawer.line_spacing
279279
turtle.goto(startx, starty)
280280
continue
281281
if isinstance(colours, str):
@@ -312,7 +312,7 @@ def draw_string(self, fontname, string, fontsize, colours='#000000', thicknesses
312312
if string[cidx] in ['\n', '\r']:
313313
# newline
314314
with turtle.jump_stitch():
315-
starty -= fontsize*LetterDrawer.line_spacing
315+
starty += fontsize*LetterDrawer.line_spacing
316316
turtle.goto(startx, starty)
317317
else:
318318
if isinstance(colours, str):

src/turtlethread/turtle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def visualise(self, turtle=None, width=800, height=800, scale=1, speed=6, trace_
530530
# Errors when you close the window! Yikes
531531
pass
532532

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):
533+
def fast_visualise(self, turtle=None, width=800, height=800, scale=1, speed=6, extra_speed=1, trace_jump=False, skip=False, check_density=True, done=True, bye=True):
534534
"""A fast version of the visualise() function, though it has undergone less testing.
535535
536536
Parameters
@@ -562,7 +562,7 @@ def fast_visualise(self, turtle=None, width=800, height=800, scale=1, speed=6, t
562562
try:
563563
fast_visualise(
564564
self,
565-
turtle=turtle, width=width, height=height, scale=scale, speed=speed, trace_jump=trace_jump, skip=skip,
565+
turtle=turtle, width=width, height=height, scale=scale, speed=speed, extra_speed=extra_speed, trace_jump=trace_jump, skip=skip,
566566
check_density=check_density, done=done, bye=bye
567567
)
568568
except Exception as e:

src/turtlethread/visualise.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def density_from_points(pts, dist=0.5, num=20):
359359

360360

361361
from . import stitches
362-
def fast_visualise(te, turtle=None, width=800, height=800, scale=1, speed=6, trace_jump=False, skip=False,
362+
def fast_visualise(te, turtle=None, width=800, height=800, scale=1, speed=0, extra_speed=1, trace_jump=False, skip=False,
363363
check_density=True, done=True, bye=True):
364364
"""Use the builtin ``turtle`` library to visualise an embroidery pattern.
365365
@@ -517,8 +517,9 @@ def fast_visualise(te, turtle=None, width=800, height=800, scale=1, speed=6, tra
517517
#speedup |= isinstance(te.pattern.stitch_groups[i]._parent_stitch_group, stitches.SatinStitch)
518518
speedup = te.pattern.stitch_groups[i].__class__.speedup
519519
if speedup:
520-
prev_refresh_rate = turtle._tracer()
521-
turtle._tracer(prev_refresh_rate+speedup)
520+
turtle._tracer(extra_speed+speedup)
521+
else:
522+
turtle._tracer(extra_speed)
522523

523524
#for x, y, command in progressbar(pattern.stitches):
524525
for x, y, command in te.pattern.get_pyembroidery_of(i).stitches:
@@ -572,8 +573,6 @@ def fast_visualise(te, turtle=None, width=800, height=800, scale=1, speed=6, tra
572573
raise_error = True
573574
break
574575

575-
if speedup:
576-
turtle._tracer(prev_refresh_rate)
577576

578577
if skip:
579578
turtle._update()

0 commit comments

Comments
 (0)