Class: Plushie::Canvas::Shape::Line
- Inherits:
-
Data
- Object
- Data
- Plushie::Canvas::Shape::Line
- Defined in:
- lib/plushie/canvas/shape/line.rb
Overview
Line shape.
Instance Attribute Summary collapse
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#stroke ⇒ Object
readonly
Returns the value of attribute stroke.
-
#stroke_width ⇒ Object
readonly
Returns the value of attribute stroke_width.
-
#x1 ⇒ Object
readonly
Returns the value of attribute x1.
-
#x2 ⇒ Object
readonly
Returns the value of attribute x2.
-
#y1 ⇒ Object
readonly
Returns the value of attribute y1.
-
#y2 ⇒ Object
readonly
Returns the value of attribute y2.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access shape properties by key.
-
#initialize(x1:, y1:, x2:, y2:, stroke: nil, stroke_width: nil, opacity: nil) ⇒ Line
constructor
A new instance of Line.
-
#to_wire ⇒ Object
private
Encode shape for the wire protocol.
Constructor Details
#initialize(x1:, y1:, x2:, y2:, stroke: nil, stroke_width: nil, opacity: nil) ⇒ Line
Returns a new instance of Line.
8 9 10 |
# File 'lib/plushie/canvas/shape/line.rb', line 8 def initialize(x1:, y1:, x2:, y2:, stroke: nil, stroke_width: nil, opacity: nil) super end |
Instance Attribute Details
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def opacity @opacity end |
#stroke ⇒ Object (readonly)
Returns the value of attribute stroke
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def stroke @stroke end |
#stroke_width ⇒ Object (readonly)
Returns the value of attribute stroke_width
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def stroke_width @stroke_width end |
#x1 ⇒ Object (readonly)
Returns the value of attribute x1
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def x1 @x1 end |
#x2 ⇒ Object (readonly)
Returns the value of attribute x2
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def x2 @x2 end |
#y1 ⇒ Object (readonly)
Returns the value of attribute y1
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def y1 @y1 end |
#y2 ⇒ Object (readonly)
Returns the value of attribute y2
7 8 9 |
# File 'lib/plushie/canvas/shape/line.rb', line 7 def y2 @y2 end |
Instance Method Details
#[](key) ⇒ Object
Access shape properties by key.
16 |
# File 'lib/plushie/canvas/shape/line.rb', line 16 def [](key) = to_wire[key] |
#to_wire ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Encode shape for the wire protocol.
20 21 22 23 24 25 26 |
# File 'lib/plushie/canvas/shape/line.rb', line 20 def to_wire h = {type: "line", x1: x1, y1: y1, x2: x2, y2: y2} h[:stroke] = stroke if stroke h[:stroke_width] = stroke_width if stroke_width h[:opacity] = opacity if opacity h end |