From 93d02138d8bbe474a0ef098da8cb08803bef2004 Mon Sep 17 00:00:00 2001 From: Yutaka HARA Date: Fri, 31 Jan 2020 00:39:02 +0900 Subject: [PATCH] examples: Fix flickering on PC browser 788dc30946141ffde92c9689622f7cb87004a0ca causes flicker on PC browsers. This is the correct fix. --- examples/multi_touch/main.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/multi_touch/main.rb b/examples/multi_touch/main.rb index c7201c5..4186fea 100644 --- a/examples/multi_touch/main.rb +++ b/examples/multi_touch/main.rb @@ -15,14 +15,6 @@ def random_color Window.loop do Window.draw_font(0, 0, "Multi touch demo\n(Open with mobile device)", Font.default) - closing_circles.map!{|(x, y, radius, color)| - Window.draw_circle_fill(x, y, radius, color) - [x, y, radius-1, color] - } - closing_circles.delete_if{|(x, y, radius, color)| - radius <= 0 - } - # Mouse support (for PCs) if Input.mouse_down?(M_LBUTTON) if mouse_circle @@ -45,10 +37,19 @@ def random_color end Input.touches.each do |t| t.data[:radius] += 1 - Window.draw_circle_fill(t.x, t.y, t.data[:radius], t.data[:color]) if t.released? closing_circles << [t.x, t.y, t.data[:radius], t.data[:color]] + else + Window.draw_circle_fill(t.x, t.y, t.data[:radius], t.data[:color]) end end + + closing_circles.map!{|(x, y, radius, color)| + Window.draw_circle_fill(x, y, radius, color) + [x, y, radius-1, color] + } + closing_circles.delete_if{|(x, y, radius, color)| + radius <= 0 + } end end