@@ -137,6 +137,9 @@ def convert_colour(strcolour):
137
137
if strcolour is not None :
138
138
if strcolour .startswith ('#' ) and len (strcolour ) == 4 :
139
139
strcolour = '#{0}{0}{1}{1}{2}{2}' .format (* strcolour [1 :])
140
+ elif strcolour .strip ().lower () == 'transparent' :
141
+ #hmm
142
+ strcolour = 'none'
140
143
return strcolour
141
144
142
145
def rev_update (self , other ):
@@ -208,7 +211,7 @@ def parse_length(self, input, horiz):
208
211
''' Parses an input length to user units '''
209
212
if input is None :
210
213
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 )
212
215
if not m :
213
216
raise ValueError ("Invalid input: " + input )
214
217
value = float (m .group (1 ))
@@ -478,7 +481,7 @@ def cubicbezier(self, points, t, relative):
478
481
precision = 0.05
479
482
for i in range (0 , len (points ), 3 ):
480
483
cp = self .upos
481
- lastcp = points [i + 1 ]
484
+ lastcp = ( points [i + 1 ], points [ i + 2 ])
482
485
if relative :
483
486
print (i , len (points ), points )
484
487
points [i ] += cp
@@ -560,6 +563,8 @@ def render(self, t):
560
563
else :
561
564
# FIXME: Not really reflection
562
565
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]
563
568
# if command == 's':
564
569
# lastcp[0], lastcp[1] = -lastcp[0], -lastcp[1]
565
570
# else:
@@ -739,12 +744,20 @@ def render(self, t, setup=True, width=None):
739
744
rwidth = width
740
745
rheight *= scale
741
746
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 )
742
752
t .screen .setup (rwidth , rheight , 0 , 0 )
743
- t .screen .reset ()
744
753
# This is a bit of a hack; it offsets the 0 position by the size of the turtle
745
754
# 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 ()
747
759
# t.speed(1)
760
+ t .screen .update ()
748
761
t .speed (0 )
749
762
t .showturtle ()
750
763
self .base .render (TurtleWrapper (t ))
@@ -757,3 +770,7 @@ def demo(file, width=None):
757
770
a = TurtleSVG (file )
758
771
a .render (t , width = width )
759
772
turtle .mainloop ()
773
+
774
+ if __name__ == "__main__" :
775
+ import sys
776
+ demo (sys .argv [1 ], 700 )
0 commit comments