Sha256: 61b8d041178849059cbdae456465657414ed88b6a129380340f5f4edd66da7b2
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
#-- # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # Version 2, December 2004 # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION # # 0. You just DO WHAT THE FUCK YOU WANT TO. #++ 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 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.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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
opal-browser-0.1.0.beta1 | opal/browser/canvas/data.rb |