Class: Dommy::ImageData
- Inherits:
-
Object
- Object
- Dommy::ImageData
- Defined in:
- lib/dommy/html_canvas_element.rb
Overview
ctx.getImageData(...) / createImageData(...) result: width, height, and a
zeroed RGBA data buffer of length widthheight4 (a plain numeric array,
which supports the .length and data[i] reads canvas code does).
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
- #__js_set__(_key, _value) ⇒ Object
-
#initialize(width, height) ⇒ ImageData
constructor
A new instance of ImageData.
Constructor Details
#initialize(width, height) ⇒ ImageData
Returns a new instance of ImageData.
212 213 214 215 216 |
# File 'lib/dommy/html_canvas_element.rb', line 212 def initialize(width, height) @width = [width.to_i, 0].max @height = [height.to_i, 0].max @data = Array.new(@width * @height * 4, 0) end |
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
210 211 212 |
# File 'lib/dommy/html_canvas_element.rb', line 210 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
210 211 212 |
# File 'lib/dommy/html_canvas_element.rb', line 210 def width @width end |