@@ -33,7 +33,7 @@ def mouse_click(self, x, y):
33
33
def mouse_move (self , x , y ):
34
34
raise NotImplementedError
35
35
36
- def exec (self , exec_str ):
36
+ def execute (self , exec_str ):
37
37
"Stores the command to be exectued to a list which is used later during update()"
38
38
if not isinstance (exec_str , str ):
39
39
print ("Invalid execution argument:" ,exec_str )
@@ -43,19 +43,19 @@ def exec(self, exec_str):
43
43
44
44
def fill (self , r , g , b ):
45
45
"Changes the fill color to a color in rgb format"
46
- self .exec ("fill({0}, {1}, {2})" .format (r , g , b ))
46
+ self .execute ("fill({0}, {1}, {2})" .format (r , g , b ))
47
47
48
48
def stroke (self , r , g , b ):
49
49
"Changes the colors of line/strokes to rgb"
50
- self .exec ("stroke({0}, {1}, {2})" .format (r , g , b ))
50
+ self .execute ("stroke({0}, {1}, {2})" .format (r , g , b ))
51
51
52
52
def strokeWidth (self , w ):
53
53
"Changes the width of lines/strokes to 'w' pixels"
54
- self .exec ("strokeWidth({0})" .format (w ))
54
+ self .execute ("strokeWidth({0})" .format (w ))
55
55
56
56
def rect (self , x , y , w , h ):
57
57
"Draw a rectangle with 'w' width, 'h' height and (x, y) as the top-left corner"
58
- self .exec ("rect({0}, {1}, {2}, {3})" .format (x , y , w , h ))
58
+ self .execute ("rect({0}, {1}, {2}, {3})" .format (x , y , w , h ))
59
59
60
60
def rect_n (self , xn , yn , wn , hn ):
61
61
"Similar to rect(), but the dimensions are normalized to fall between 0 and 1"
@@ -67,7 +67,7 @@ def rect_n(self, xn, yn, wn, hn):
67
67
68
68
def line (self , x1 , y1 , x2 , y2 ):
69
69
"Draw a line from (x1, y1) to (x2, y2)"
70
- self .exec ("line({0}, {1}, {2}, {3})" .format (x1 , y1 , x2 , y2 ))
70
+ self .execute ("line({0}, {1}, {2}, {3})" .format (x1 , y1 , x2 , y2 ))
71
71
72
72
def line_n (self , x1n , y1n , x2n , y2n ):
73
73
"Similar to line(), but the dimensions are normalized to fall between 0 and 1"
@@ -79,7 +79,7 @@ def line_n(self, x1n, y1n, x2n, y2n):
79
79
80
80
def arc (self , x , y , r , start , stop ):
81
81
"Draw an arc with (x, y) as centre, 'r' as radius from angles 'start' to 'stop'"
82
- self .exec ("arc({0}, {1}, {2}, {3}, {4})" .format (x , y , r , start , stop ))
82
+ self .execute ("arc({0}, {1}, {2}, {3}, {4})" .format (x , y , r , start , stop ))
83
83
84
84
def arc_n (self , xn ,yn , rn , start , stop ):
85
85
"""Similar to arc(), but the dimensions are normalized to fall between 0 and 1
@@ -92,18 +92,18 @@ def arc_n(self, xn ,yn, rn, start, stop):
92
92
93
93
def clear (self ):
94
94
"Clear the HTML canvas"
95
- self .exec ("clear()" )
95
+ self .execute ("clear()" )
96
96
97
97
def font (self , font ):
98
98
"Changes the font of text"
99
- self .exec ('font("{0}")' .format (font ))
99
+ self .execute ('font("{0}")' .format (font ))
100
100
101
101
def text (self , txt , x , y , fill = True ):
102
102
"Display a text at (x, y)"
103
103
if fill :
104
- self .exec ('fill_text("{0}", {1}, {2})' .format (txt , x , y ))
104
+ self .execute ('fill_text("{0}", {1}, {2})' .format (txt , x , y ))
105
105
else :
106
- self .exec ('stroke_text("{0}", {1}, {2})' .format (txt , x , y ))
106
+ self .execute ('stroke_text("{0}", {1}, {2})' .format (txt , x , y ))
107
107
108
108
def text_n (self , txt , xn , yn , fill = True ):
109
109
"Similar to text(), but with normalized coordinates"
@@ -116,7 +116,7 @@ def alert(self, message):
116
116
display (HTML ('<script>alert("{0}")</script>' .format (message )))
117
117
118
118
def update (self ):
119
- "Execute the JS code to execute the commands queued by exec ()"
119
+ "Execute the JS code to execute the commands queued by execute ()"
120
120
exec_code = "<script>\n " + '\n ' .join (self .exec_list )+ "\n </script>"
121
121
self .exec_list = []
122
122
display (HTML (exec_code ))
0 commit comments