Sha256: d68c7a1c5a7750a9b38ca9f07df41ff6470fb82e4a92a0bd30a2deb505ea2f1d
Contents?: true
Size: 1 KB
Versions: 6
Compression:
Stored size: 1 KB
Contents
module Browser; class Canvas class Data def self.create(canvas, width, height) data = allocate data.instance_eval { @canvas = canvas.to_a @x = 0 @y = 0 @width = width @height = height @native = `#{canvas.to_n}.createImageData(width, height)` } data end include Native::Wrapper attr_reader :x, :y, :width, :height def initialize(canvas, x, y, width, height) @canvas = canvas.to_n @x = x @y = y @width = width @height = height super(`#@canvas.getImageData(x, y, width, height)`) end def length `#@native.data.length` end def [](index) `#@native.data[index]` end def []=(index, value) `#@native.data[index] = value` end def save(x = nil, y = nil) x ||= 0 y ||= 0 `#@canvas.putImageData(#@native, x, y)` end def save_to(canvas, x = nil, y = nil) x ||= 0 y ||= 0 `#{canvas.to_n}.putImageData(#@native, x, y)` end alias size length end end; end
Version data entries
6 entries across 6 versions & 2 rubygems