Class: Plushie::Canvas::Shape::CanvasImage
- Inherits:
-
Data
- Object
- Data
- Plushie::Canvas::Shape::CanvasImage
- Defined in:
- lib/plushie/canvas/shape/canvas_image.rb
Overview
Canvas raster image shape with position, size, and optional rotation.
Instance Attribute Summary collapse
-
#h ⇒ Object
readonly
Returns the value of attribute h.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#rotation ⇒ Object
readonly
Returns the value of attribute rotation.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#w ⇒ Object
readonly
Returns the value of attribute w.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Backward-compatible hash-style access.
-
#initialize(source:, x:, y:, w:, h:, rotation: nil, opacity: nil) ⇒ CanvasImage
constructor
A new instance of CanvasImage.
-
#to_wire ⇒ Hash
Wire-ready shape map.
Constructor Details
#initialize(source:, x:, y:, w:, h:, rotation: nil, opacity: nil) ⇒ CanvasImage
Returns a new instance of CanvasImage.
12 13 14 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 12 def initialize(source:, x:, y:, w:, h:, rotation: nil, opacity: nil) super end |
Instance Attribute Details
#h ⇒ Object (readonly)
Returns the value of attribute h
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def h @h end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def opacity @opacity end |
#rotation ⇒ Object (readonly)
Returns the value of attribute rotation
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def rotation @rotation end |
#source ⇒ Object (readonly)
Returns the value of attribute source
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def source @source end |
#w ⇒ Object (readonly)
Returns the value of attribute w
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def w @w end |
#x ⇒ Object (readonly)
Returns the value of attribute x
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y
11 12 13 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 11 def y @y end |
Instance Method Details
#[](key) ⇒ Object
Backward-compatible hash-style access.
17 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 17 def [](key) = to_wire[key] |
#to_wire ⇒ Hash
Returns wire-ready shape map.
20 21 22 23 24 25 |
# File 'lib/plushie/canvas/shape/canvas_image.rb', line 20 def to_wire h = {type: "image", source: source, x: x, y: y, w: w, h: self.h} h[:rotation] = rotation if rotation h[:opacity] = opacity if opacity h end |