Class: RubySketch::SnapConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- RubySketch::SnapConstraint
- Defined in:
- lib/rubysketch/constraint.rb
Overview
Snaps two points together like a hinge.
Instance Method Summary collapse
-
#angle ⇒ Range?
Returns the range of the relative rotation angle.
-
#angle=(angle) ⇒ Range, ...
Sets the range of the relative rotation angle.
-
#motor ⇒ Numeric?
Returns the motor speed.
-
#motor=(speed) ⇒ Numeric?
Sets the motor speed that drives the relative rotation.
Methods inherited from Constraint
#active?, #collide=, #collide?, #damping, #damping=, #force, #force=, #remove, #removed?, #spring, #spring=, #sprites
Instance Method Details
#angle ⇒ Range?
Returns the range of the relative rotation angle.
198 199 200 201 |
# File 'lib/rubysketch/constraint.rb', line 198 def angle() angle = @constraint__.angle angle ? Range.new(fromDegrees__(angle.begin), fromDegrees__(angle.end)) : nil end |
#angle=(angle) ⇒ Range, ...
Sets the range of the relative rotation angle.
185 186 187 188 189 190 191 192 |
# File 'lib/rubysketch/constraint.rb', line 185 def angle=(angle) @constraint__.angle = case angle when Range then Range.new toDegrees__(angle.begin), toDegrees__(angle.end) when Numeric then toDegrees__ angle else angle end end |
#motor ⇒ Numeric?
Returns the motor speed.
219 220 221 222 |
# File 'lib/rubysketch/constraint.rb', line 219 def motor() speed = @constraint__.motor speed && fromDegrees__(speed) end |
#motor=(speed) ⇒ Numeric?
Sets the motor speed that drives the relative rotation.
211 212 213 |
# File 'lib/rubysketch/constraint.rb', line 211 def motor=(speed) @constraint__.motor = speed && toDegrees__(speed) end |