Skip to content

Commit 2300e59

Browse files
committed
commit changes i don't even remember making
1 parent 9801067 commit 2300e59

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

turtlesvg.py

+21-4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ def convert_colour(strcolour):
137137
if strcolour is not None:
138138
if strcolour.startswith('#') and len(strcolour) == 4:
139139
strcolour = '#{0}{0}{1}{1}{2}{2}'.format(*strcolour[1:])
140+
elif strcolour.strip().lower() == 'transparent':
141+
#hmm
142+
strcolour = 'none'
140143
return strcolour
141144

142145
def rev_update(self, other):
@@ -208,7 +211,7 @@ def parse_length(self, input, horiz):
208211
''' Parses an input length to user units '''
209212
if input is None:
210213
return 0
211-
m = re.match(r'^([+-]?[\d]+(?:\.[\d]*?)?)([a-zA-Z%]+)?$', input)
214+
m = re.match(r'^([+-]?[\d]+(?:\.[\d]*?)?(?:[eE][-+]?[0-9]+)?)([a-zA-Z%]+)?$', input)
212215
if not m:
213216
raise ValueError("Invalid input: " + input)
214217
value = float(m.group(1))
@@ -478,7 +481,7 @@ def cubicbezier(self, points, t, relative):
478481
precision = 0.05
479482
for i in range(0, len(points), 3):
480483
cp = self.upos
481-
lastcp = points[i + 1]
484+
lastcp = (points[i + 1], points[i+2])
482485
if relative:
483486
print(i, len(points), points)
484487
points[i] += cp
@@ -560,6 +563,8 @@ def render(self, t):
560563
else:
561564
# FIXME: Not really reflection
562565
print("REFLECTION: Before", lastcp)
566+
lastcp = Point(2. * lastcp[1].x - lastcp[0].x, 2. * lastcp[1].y - lastcp[0].y)
567+
#lastcp = lastcp[0]
563568
# if command == 's':
564569
# lastcp[0], lastcp[1] = -lastcp[0], -lastcp[1]
565570
# else:
@@ -739,12 +744,20 @@ def render(self, t, setup=True, width=None):
739744
rwidth = width
740745
rheight *= scale
741746
self.base.transform(TransformationMatrix.scale(scale))
747+
print("SCREEN", rwidth, rheight)
748+
# Get rid of most of the border that screws up positioning
749+
cv = t.screen.getcanvas()
750+
cv.config(highlightthickness=0, bd=0, relief='flat')
751+
cv.winfo_toplevel().config(width=0, height=0, padx=0, pady=0)
742752
t.screen.setup(rwidth, rheight, 0, 0)
743-
t.screen.reset()
744753
# This is a bit of a hack; it offsets the 0 position by the size of the turtle
745754
# Hardcoded to 8 pixels for now...
746-
t.screen.setworldcoordinates(8, rheight, rwidth, 8)
755+
t.screen.setworldcoordinates(9, rheight-9, rwidth-9, 9)
756+
t.screen.reset()
757+
cv.pack()
758+
cv.winfo_toplevel().update()
747759
# t.speed(1)
760+
t.screen.update()
748761
t.speed(0)
749762
t.showturtle()
750763
self.base.render(TurtleWrapper(t))
@@ -757,3 +770,7 @@ def demo(file, width=None):
757770
a = TurtleSVG(file)
758771
a.render(t, width=width)
759772
turtle.mainloop()
773+
774+
if __name__ == "__main__":
775+
import sys
776+
demo(sys.argv[1], 700)

0 commit comments

Comments
 (0)