Skip to content

Commit a04eab1

Browse files
committed
hello-gui with separate layers
1 parent db889e3 commit a04eab1

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pdlua/hello-gui.pd_lua

+12-8
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function hello:mouse_drag(x, y)
6060
self.draggable_rect_y = self.rect_down_pos[1] + (y - self.mouse_down_pos[1])
6161
self.draggable_rect_x = math.clamp(self.draggable_rect_x, 0, 620 - self.draggable_rect_size)
6262
self.draggable_rect_y = math.clamp(self.draggable_rect_y, 0, 230 - self.draggable_rect_size)
63-
self:repaint()
63+
self:repaint(3)
6464
end
6565
end
6666

@@ -144,12 +144,6 @@ function hello:paint(g)
144144
g:fill_path(curve2)
145145
g:reset_transform()
146146

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-
153147
-- Titles
154148
g:set_color(252, 118, 81, 1)
155149
g:draw_text("Ellipse", 25, 190, 120, 12)
@@ -159,17 +153,27 @@ function hello:paint(g)
159153
g:draw_text("Bezier Paths", 360, 190, 120, 12)
160154
g:draw_text("Animation", 460, 190, 120, 12)
161155
g:draw_text(" Mouse\nInteraction", 540, 190, 120, 12)
156+
end
162157

158+
function hello:paint_layer_2(g)
163159
g:set_color(250, 84, 108, 1)
164160
g:fill_ellipse(self.circle_x, self.circle_y, self.circle_radius, self.circle_radius)
165161
end
166162

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+
167171
function hello:tick()
168172
self.circle_y = self.circle_y + self.animation_speed
169173
if self.circle_y > 160 + self.circle_radius then
170174
self.circle_y = -self.circle_radius
171175
end
172-
self:repaint()
176+
self:repaint(2)
173177
self.clock:delay(self.delay_time)
174178
end
175179

0 commit comments

Comments
 (0)