Class: Plushie::Canvas::Shape::ShapeStyle
- Inherits:
-
Data
- Object
- Data
- Plushie::Canvas::Shape::ShapeStyle
- Defined in:
- lib/plushie/canvas/shape/shape_style.rb
Overview
Style overrides for interactive canvas shape states (hover, pressed).
Instance Attribute Summary collapse
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#stroke ⇒ Object
readonly
Returns the value of attribute stroke.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Backward-compatible hash-style access.
-
#initialize(fill: nil, stroke: nil, opacity: nil) ⇒ ShapeStyle
constructor
A new instance of ShapeStyle.
-
#to_wire ⇒ Hash
Wire-ready style map (nil fields stripped).
Constructor Details
#initialize(fill: nil, stroke: nil, opacity: nil) ⇒ ShapeStyle
Returns a new instance of ShapeStyle.
12 13 14 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 12 def initialize(fill: nil, stroke: nil, opacity: nil) super end |
Instance Attribute Details
#fill ⇒ Object (readonly)
Returns the value of attribute fill
11 12 13 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 11 def fill @fill end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity
11 12 13 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 11 def opacity @opacity end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke
11 12 13 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 11 def stroke @stroke end |
Instance Method Details
#[](key) ⇒ Object
Backward-compatible hash-style access.
17 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 17 def [](key) = to_wire[key] |
#to_wire ⇒ Hash
Returns wire-ready style map (nil fields stripped).
20 21 22 23 24 25 26 |
# File 'lib/plushie/canvas/shape/shape_style.rb', line 20 def to_wire h = {} h[:fill] = fill if fill h[:stroke] = stroke if stroke h[:opacity] = opacity if opacity h end |