66
77attr_reader :sources , :sel , :video , :corners , :quads , :last_mouse_move
88RES = 5 # number of subdivisions (e.g. 5 x 5)
9+ NONE = -1
910
1011def setup
1112 @last_mouse_move = 0
@@ -24,11 +25,11 @@ def draw
2425 video . read if sel . respond_to? ( :read ) && video . available
2526 # regenerate mesh if we're dragging a corner
2627 if corners . selected? && ( pmouse_x != mouse_x || pmouse_y != mouse_y )
27- corners . set_corner ( mouse_x , mouse_y )
28+ corners . change_selected ( mouse_x , mouse_y )
2829 # this improves performance, but will be replaced by a
2930 # more elegant way in a future release
3031 @quads = [ ]
31- Java ::JavaLang ::System . gc # this is generally not recommended
32+ # Java::JavaLang::System.gc # this is generally not recommended
3233 @quads = create_mesh ( sel , corners , RES )
3334 end
3435
@@ -46,15 +47,15 @@ def draw
4647
4748def mouse_pressed
4849 corners . each_with_index do |corner , i |
49- return corners . set_index ( i ) if dist ( mouse_x , mouse_y , corner . x , corner . y ) < 20
50+ return corners . select_corner ( i ) if dist ( mouse_x , mouse_y , corner . x , corner . y ) < 20
5051 end
5152 # no corner? then switch texture
5253 @sel = sel . respond_to? ( :loop ) ? sources . image : sources . video
5354 @quads = create_mesh ( sel , corners , RES )
5455end
5556
5657def mouse_released
57- corners . set_index ( - 1 )
58+ corners . select_corner ( NONE )
5859end
5960
6061def create_mesh ( tex , corners , res )
0 commit comments