Class: Plushie::Canvas::Shape::CanvasText
- Inherits:
-
Data
- Object
- Data
- Plushie::Canvas::Shape::CanvasText
- Defined in:
- lib/plushie/canvas/shape/canvas_text.rb
Overview
Text drawn on a canvas.
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#font ⇒ Object
readonly
Returns the value of attribute font.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Access shape properties by key.
-
#initialize(x:, y:, content:, fill: nil, size: nil, font: nil, opacity: nil) ⇒ CanvasText
constructor
A new instance of CanvasText.
-
#to_wire ⇒ Object
private
Encode shape for the wire protocol.
Constructor Details
#initialize(x:, y:, content:, fill: nil, size: nil, font: nil, opacity: nil) ⇒ CanvasText
Returns a new instance of CanvasText.
8 9 10 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 8 def initialize(x:, y:, content:, fill: nil, size: nil, font: nil, opacity: nil) super end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def content @content end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def fill @fill end |
#font ⇒ Object (readonly)
Returns the value of attribute font
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def font @font end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def opacity @opacity end |
#size ⇒ Object (readonly)
Returns the value of attribute size
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def size @size end |
#x ⇒ Object (readonly)
Returns the value of attribute x
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y
7 8 9 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7 def y @y end |
Instance Method Details
#[](key) ⇒ Object
Access shape properties by key.
16 |
# File 'lib/plushie/canvas/shape/canvas_text.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 27 |
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 20 def to_wire h = {type: "text", x: x, y: y, content: content} h[:fill] = fill if fill h[:size] = size if size h[:font] = font if font h[:opacity] = opacity if opacity h end |