class StumpyCore::Canvas
- StumpyCore::Canvas
- Reference
- Object
Overview
A canvas is 2D array of RGBA
pixels
To create a canvas of size 400
x 200
canvas = StumpyCore::Canvas.new(400, 200)
The default background color is transparent,
but it can be passed in as a parameter or as a block
that returns the color value for each {x, y}
pair.
canvas2 = StumpyCore::Canvas.new(400, 200, RGBA::WHITE)
canvas3 = StumpyCore::Canvas.new(256, 256) do |x, y|
RGBA.from_rgb_n(x, y, 255, 8)
end
Because of the way pixels are stored in a Slice
,
Canvas
es are limited to Int32::MAX = 2147483647
pixels in total,
e.g. a maximal size of 46340x46340 for a square image.
Defined in:
lib/stumpy_core/src/stumpy_core/canvas.crnya/stumpy_core_ext.cr