@@ -52,16 +52,15 @@ def draw
5252end
5353
5454def draw_lights
55- lights = create_graphics width , height , P2D
56- lights . begin_draw
57- @flyers . each do | flyer |
58- lights . push_matrix
59- position = flyer . pos
60- lights . translate position . x , position . y
61- lights . image @spotlight , - @spotlight . width / 2 , - @spotlight . height / 2
62- lights . pop_matrix
55+ lights = buffer ( width , height , P2D ) do | buffer |
56+ @flyers . each do | flyer |
57+ buffer . push_matrix
58+ position = flyer . pos
59+ buffer . translate position . x , position . y
60+ buffer . image @spotlight , - @spotlight . width / 2 , - @spotlight . height / 2
61+ buffer . pop_matrix
62+ end
6363 end
64- lights . end_draw
6564 image_mask . mask lights
6665 image image_mask , 0 , 0
6766end
@@ -152,14 +151,12 @@ def find_nearest_rotation(from, to)
152151
153152def create_spotlight
154153 size = 60
155- spotlight = create_graphics size , size , P2D
156- spotlight . begin_draw
157- spotlight . no_stroke
158- spotlight . fill 255 , 60
159- # spotlight.fill 255, 40
160154 half_size = size / 2
161- spotlight . ellipse half_size , half_size , half_size , half_size
162- spotlight . filter BLUR , 4
163- spotlight . end_draw
164- spotlight
155+ spotlight = buffer ( size , size , P2D ) do |buffer |
156+ buffer . no_stroke
157+ buffer . fill 255 , 60
158+ # spotlight.fill 255, 40
159+ buffer . ellipse half_size , half_size , half_size , half_size
160+ buffer . filter BLUR , 4
161+ end
165162end
0 commit comments