Class: Dommy::ImageData

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#heightObject (readonly)

Returns the value of attribute height.



210
211
212
# File 'lib/dommy/html_canvas_element.rb', line 210

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



210
211
212
# File 'lib/dommy/html_canvas_element.rb', line 210

def width
  @width
end

Instance Method Details

#__js_get__(key) ⇒ Object



218
219
220
221
222
223
224
225
226
# File 'lib/dommy/html_canvas_element.rb', line 218

def __js_get__(key)
  case key
  when "width" then @width
  when "height" then @height
  when "data" then @data
  when "colorSpace" then "srgb"
  else Bridge::ABSENT
  end
end

#__js_set__(_key, _value) ⇒ Object



228
# File 'lib/dommy/html_canvas_element.rb', line 228

def __js_set__(_key, _value) = Bridge::UNHANDLED