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.
73 74 75 76 77 |
# File 'lib/origami/graphics/path.rb', line 73 def initialize @segments = [] @current_point = nil @closed = false end |
Instance Attribute Details
#current_point ⇒ Object
Returns the value of attribute current_point.
70 71 72 |
# File 'lib/origami/graphics/path.rb', line 70 def current_point @current_point end |
#segments ⇒ Object (readonly)
Returns the value of attribute segments.
71 72 73 |
# File 'lib/origami/graphics/path.rb', line 71 def segments @segments end |
Instance Method Details
#add_segment(seg) ⇒ Object
92 93 94 95 96 97 |
# File 'lib/origami/graphics/path.rb', line 92 def add_segment(seg) raise GraphicsStateError, "Cannot modify closed subpath" if is_closed? @segments << seg @current_point = seg.to end |
#close! ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/origami/graphics/path.rb', line 83 def close! from = @current_point to = @segments.first.from @segments << Line.new(from, to) @segments.freeze @closed = true end |
#is_closed? ⇒ Boolean
79 80 81 |
# File 'lib/origami/graphics/path.rb', line 79 def is_closed? @closed end |