Class: Plushie::Canvas::Shape::Stroke
- Inherits:
-
Data
- Object
- Data
- Plushie::Canvas::Shape::Stroke
- Defined in:
- lib/plushie/canvas/shape/stroke.rb
Overview
Canvas stroke descriptor with color, width, and optional cap/join/dash.
Instance Attribute Summary collapse
-
#cap ⇒ Object
readonly
Returns the value of attribute cap.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#dash ⇒ Object
readonly
Returns the value of attribute dash.
-
#join ⇒ Object
readonly
Returns the value of attribute join.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Backward-compatible hash-style access.
-
#initialize(color:, width:, cap: nil, join: nil, dash: nil) ⇒ Stroke
constructor
A new instance of Stroke.
-
#to_wire ⇒ Hash
Wire-ready stroke map.
Constructor Details
#initialize(color:, width:, cap: nil, join: nil, dash: nil) ⇒ Stroke
Returns a new instance of Stroke.
13 14 15 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 13 def initialize(color:, width:, cap: nil, join: nil, dash: nil) super end |
Instance Attribute Details
#cap ⇒ Object (readonly)
Returns the value of attribute cap
12 13 14 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 12 def cap @cap end |
#color ⇒ Object (readonly)
Returns the value of attribute color
12 13 14 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 12 def color @color end |
#dash ⇒ Object (readonly)
Returns the value of attribute dash
12 13 14 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 12 def dash @dash end |
#join ⇒ Object (readonly)
Returns the value of attribute join
12 13 14 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 12 def join @join end |
#width ⇒ Object (readonly)
Returns the value of attribute width
12 13 14 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 12 def width @width end |
Instance Method Details
#[](key) ⇒ Object
Backward-compatible hash-style access.
18 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 18 def [](key) = to_wire[key] |
#to_wire ⇒ Hash
Returns wire-ready stroke map.
21 22 23 24 25 26 27 |
# File 'lib/plushie/canvas/shape/stroke.rb', line 21 def to_wire h = {color: color, width: width} h[:cap] = cap if cap h[:join] = join if join h[:dash] = dash.respond_to?(:to_wire) ? dash.to_wire : dash if dash h end |