MCPcopy Create free account
hub / github.com/coldtype/coldtype / draw

Method draw

examples/axidraw/nextdraw.py:52–107  ·  view source on GitHub ↗
(self,
        scale=0.01,
        cm=False,
        ad=None,
        move_delay=0,
        zero=True,
        )

Source from the content-addressed store, hash-verified

50 self.ad.lineto(*self.last_moveTo)
51
52 def draw(self,
53 scale=0.01,
54 cm=False,
55 ad=None,
56 move_delay=0,
57 zero=True,
58 ):
59
60 self.dat.scale(scale, point=Point(0, 0))
61 page = self.page.scale(scale)
62 bounds = self.dat.bounds()
63
64 limits = Rect(0, 0, 11, 8.5)
65 if cm:
66 limits = limits.scale(2.54)
67
68 def small_enough(r):
69 return (r.mnx >= 0
70 and r.mny >= 0
71 and r.mxx <= limits.w
72 and r.mxy <= limits.h)
73
74 if small_enough(page) and small_enough(bounds):
75 print("Drawing!")
76 else:
77 print("Too big!", page, bounds)
78 return False
79
80 own_ad = False
81 if not ad:
82 own_ad = True
83 ad = NextDraw()
84 ad.interactive()
85 ad.options.units = 1 if cm else 0
86 ad.options.speed_pendown = 50
87 ad.options.speed_penup = 50
88 ad.options.pen_rate_raise = 50
89
90 if own_ad:
91 ad.connect()
92 ad.penup()
93 self.ad = ad
94 self.move_delay = move_delay
95
96 tp = TransformPen(self,
97 (1, 0, 0, -1, 0, page.h))
98
99 self.dat.replay(tp)
100 ad.penup()
101 time.sleep(move_delay)
102 ad.penup()
103
104 if zero:
105 ad.moveto(0,0)
106 if own_ad:
107 ad.disconnect()
108
109

Callers 13

walkerMethod · 0.95
writeGlyphMethod · 0.45
p5.min.jsFile · 0.45
oFunction · 0.45
hatching.pyFile · 0.45
sheet.pyFile · 0.45
nextdraw.pyFile · 0.45
add_glyphFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45
setupFunction · 0.45

Calls 10

scaleMethod · 0.95
PointClass · 0.90
RectClass · 0.90
scaleMethod · 0.45
boundsMethod · 0.45
connectMethod · 0.45
penupMethod · 0.45
replayMethod · 0.45
sleepMethod · 0.45
movetoMethod · 0.45

Tested by

no test coverage detected