Class: DemCurves::PathElement
- Inherits:
-
Object
- Object
- DemCurves::PathElement
- Defined in:
- lib/core/path-element.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#control_points ⇒ Object
readonly
Do not directly instantiate this class.
-
#path_points ⇒ Object
readonly
Do not directly instantiate this class.
Instance Method Summary collapse
- #[](control_id) ⇒ Object
- #[]=(control_id, loc) ⇒ Object
- #generate ⇒ Object
- #get_control(control_id) ⇒ Object
-
#initialize(control_points) ⇒ PathElement
constructor
A new instance of PathElement.
- #set_control(control_id, loc) ⇒ Object
Constructor Details
#initialize(control_points) ⇒ PathElement
Returns a new instance of PathElement.
7 8 9 10 11 12 13 14 15 |
# File 'lib/core/path-element.rb', line 7 def initialize(control_points) @control_points = control_points @control_points.each_value do |control_point| control_point.add_path_element self end @path_points = [] generate end |
Instance Attribute Details
#control_points ⇒ Object (readonly)
Do not directly instantiate this class
6 7 8 |
# File 'lib/core/path-element.rb', line 6 def control_points @control_points end |
#path_points ⇒ Object (readonly)
Do not directly instantiate this class
6 7 8 |
# File 'lib/core/path-element.rb', line 6 def path_points @path_points end |
Instance Method Details
#[](control_id) ⇒ Object
42 43 44 |
# File 'lib/core/path-element.rb', line 42 def [](control_id) get_control control_id end |
#[]=(control_id, loc) ⇒ Object
30 31 32 |
# File 'lib/core/path-element.rb', line 30 def []=(control_id, loc) set_control control_id, loc end |
#generate ⇒ Object
17 18 19 |
# File 'lib/core/path-element.rb', line 17 def generate @path_points = @control_points.values.collect {|point| point.loc} end |
#get_control(control_id) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/core/path-element.rb', line 34 def get_control(control_id) unless control_id.class == Symbol raise 'control_id must be a symbol' end return @control_points[control_id] end |
#set_control(control_id, loc) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/core/path-element.rb', line 21 def set_control(control_id, loc) unless control_id.class == Symbol raise 'control_id must be a symbol' end @control_points[control_id].move_to location generate end |