Class: DemCurves::RubygameUtils::EditorHandle
- Inherits:
-
Object
- Object
- DemCurves::RubygameUtils::EditorHandle
- Includes:
- Rubygame::Sprites::Sprite
- Defined in:
- lib/rubygame-util/control-handles.rb
Instance Method Summary collapse
- #attach_to(control_point) ⇒ Object
-
#initialize(loc = [50, 50], size = 10) ⇒ EditorHandle
constructor
A new instance of EditorHandle.
- #move(rel) ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(loc = [50, 50], size = 10) ⇒ EditorHandle
Returns a new instance of EditorHandle.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubygame-util/control-handles.rb', line 41 def initialize(loc=[50, 50], size=10) @groups =[] @depth = 0 @rect = Rubygame::Rect.new 0, 0, size, size @rect.c = loc @image = Rubygame::Surface.new [size, size], 0, [Rubygame::HWSURFACE, Rubygame::SRCALPHA] @image.fill([180, 180, 180]) @attached = false @constraints = [] end |
Instance Method Details
#attach_to(control_point) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/rubygame-util/control-handles.rb', line 55 def attach_to(control_point) unless @attached @attached = true @control_point = control_point @rect.c = control_point.loc.to_a end end |
#move(rel) ⇒ Object
63 64 65 66 67 |
# File 'lib/rubygame-util/control-handles.rb', line 63 def move(rel) if @attached @control_point.shift rel end end |
#update ⇒ Object
69 70 71 72 73 |
# File 'lib/rubygame-util/control-handles.rb', line 69 def update if @attached @rect.c = @control_point.loc.to_a end end |