Class: Origami::Graphics::Path
- Inherits:
-
Object
- Object
- Origami::Graphics::Path
- Defined in:
- lib/origami/graphics/path.rb
Defined Under Namespace
Modules: Segment Classes: Line
Instance Attribute Summary collapse
-
#current_point ⇒ Object
Returns the value of attribute current_point.
-
#segments ⇒ Object
readonly
Returns the value of attribute segments.
Instance Method Summary collapse
- #add_segment(seg) ⇒ Object
- #close! ⇒ Object
-
#initialize ⇒ Path
constructor
A new instance of Path.
- #is_closed? ⇒ Boolean
Constructor Details
#initialize ⇒ Path
Returns a new instance of Path.
77 78 79 80 81 |
# File 'lib/origami/graphics/path.rb', line 77 def initialize @segments = [] @current_point = nil @closed = false end |
Instance Attribute Details
#current_point ⇒ Object
Returns the value of attribute current_point.
74 75 76 |
# File 'lib/origami/graphics/path.rb', line 74 def current_point @current_point end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
75 76 77 |
# File 'lib/origami/graphics/path.rb', line 75 def segments @segments end |
Instance Method Details
#add_segment(seg) ⇒ Object
96 97 98 99 100 101 |
# File 'lib/origami/graphics/path.rb', line 96 def add_segment(seg) raise GraphicsStateError, "Cannot modify closed subpath" if is_closed? @segments << seg @current_point = seg.to end |
#close! ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'lib/origami/graphics/path.rb', line 87 def close! from = @current_point to = @segments.first.from @segments << Line.new(from, to) @segments.freeze @closed = true end |
#is_closed? ⇒ Boolean
83 84 85 |
# File 'lib/origami/graphics/path.rb', line 83 def is_closed? @closed end |