Class: BezierCurver::Manager
- Inherits:
-
Object
- Object
- BezierCurver::Manager
- Defined in:
- lib/bezier_curver/manager.rb
Instance Attribute Summary collapse
-
#control_points ⇒ Object
readonly
Returns the value of attribute control_points.
Instance Method Summary collapse
- #add_control_point(x, y) ⇒ Object
- #clear_all ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
#initialize ⇒ Manager
Returns a new instance of Manager.
7 8 9 10 11 12 |
# File 'lib/bezier_curver/manager.rb', line 7 def initialize @control_points = [] @point_circles = [] @curve_lines = [] @control_lines = [] end |
Instance Attribute Details
#control_points ⇒ Object (readonly)
Returns the value of attribute control_points.
5 6 7 |
# File 'lib/bezier_curver/manager.rb', line 5 def control_points @control_points end |
Instance Method Details
#add_control_point(x, y) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bezier_curver/manager.rb', line 14 def add_control_point(x, y) @control_points << [x, y] # Display control point circle = Circle.new( x: x, y: y, radius: 5, color: 'red', z: 10 ) @point_circles << circle draw_control_lines draw_bezier_curves if @control_points.length >= 5 end |
#clear_all ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bezier_curver/manager.rb', line 30 def clear_all @control_points.clear @point_circles.each(&:remove) @point_circles.clear @curve_lines.each(&:remove) @curve_lines.clear @control_lines.each(&:remove) @control_lines.clear end |