@@ -60,7 +60,7 @@ function hello:mouse_drag(x, y)
60
60
self .draggable_rect_y = self .rect_down_pos [1 ] + (y - self .mouse_down_pos [1 ])
61
61
self .draggable_rect_x = math .clamp (self .draggable_rect_x , 0 , 620 - self .draggable_rect_size )
62
62
self .draggable_rect_y = math .clamp (self .draggable_rect_y , 0 , 230 - self .draggable_rect_size )
63
- self :repaint ()
63
+ self :repaint (3 )
64
64
end
65
65
end
66
66
@@ -144,12 +144,6 @@ function hello:paint(g)
144
144
g :fill_path (curve2 )
145
145
g :reset_transform ()
146
146
147
- -- Draggable rectangle
148
- g :set_color (66 , 207 , 201 , 1 )
149
- g :fill_rounded_rect (self .draggable_rect_x , self .draggable_rect_y , self .draggable_rect_size , self .draggable_rect_size , 5 )
150
- g :set_color (0 , 0 , 0 , 1 )
151
- g :draw_text (" Drag\n me!" , self .draggable_rect_x + 8 , self .draggable_rect_y + 10 , self .draggable_rect_size , 12 )
152
-
153
147
-- Titles
154
148
g :set_color (252 , 118 , 81 , 1 )
155
149
g :draw_text (" Ellipse" , 25 , 190 , 120 , 12 )
@@ -159,17 +153,27 @@ function hello:paint(g)
159
153
g :draw_text (" Bezier Paths" , 360 , 190 , 120 , 12 )
160
154
g :draw_text (" Animation" , 460 , 190 , 120 , 12 )
161
155
g :draw_text (" Mouse\n Interaction" , 540 , 190 , 120 , 12 )
156
+ end
162
157
158
+ function hello :paint_layer_2 (g )
163
159
g :set_color (250 , 84 , 108 , 1 )
164
160
g :fill_ellipse (self .circle_x , self .circle_y , self .circle_radius , self .circle_radius )
165
161
end
166
162
163
+ function hello :paint_layer_3 (g )
164
+ -- Draggable rectangle
165
+ g :set_color (66 , 207 , 201 , 1 )
166
+ g :fill_rounded_rect (self .draggable_rect_x , self .draggable_rect_y , self .draggable_rect_size , self .draggable_rect_size , 5 )
167
+ g :set_color (0 , 0 , 0 , 1 )
168
+ g :draw_text (" Drag\n me!" , self .draggable_rect_x + 8 , self .draggable_rect_y + 10 , self .draggable_rect_size , 12 )
169
+ end
170
+
167
171
function hello :tick ()
168
172
self .circle_y = self .circle_y + self .animation_speed
169
173
if self .circle_y > 160 + self .circle_radius then
170
174
self .circle_y = - self .circle_radius
171
175
end
172
- self :repaint ()
176
+ self :repaint (2 )
173
177
self .clock :delay (self .delay_time )
174
178
end
175
179
0 commit comments