class StumpyCore::Canvas

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

image

Because of the way pixels are stored in a Slice, Canvases 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.cr
stumpy.cr

Instance Method Summary

Instance Method Detail

def to_crimage : CrImage::RGBAImage #

[View source]