class

NanoSVG::Rasterizer

Inherits Reference < Object

Constants

PI = 3.14159265358979323846264338327_f32

Class methods

rasterize(image : Image, tx : Float32, ty : Float32, scale : Float32, w : Int32, h : Int32, premultiplied : Bool = false) : Bytes

One-shot convenience (creates a throwaway rasterizer context).

Source

Instance methods

rasterize(image : Image, tx : Float32, ty : Float32, scale : Float32, dst : Bytes, w : Int32, h : Int32, stride : Int32, premultiplied : Bool = false) : Nil

Rasterizes an SVG image into a caller-provided RGBA buffer. image - parsed image (see NanoSVG.parse) tx, ty - image offset (applied after scaling) scale - image scale dst - destination buffer, 4 bytes per pixel (RGBA) stride - number of bytes per scanline in the destination buffer

dst is cleared first, so callers may reuse a buffer between calls. (Bytes.new does NOT guarantee zeroed memory — the GC hands out recycled pages — so the clear is not optional.)

premultiplied: true skips the final unpremultiply+defringe pass and returns RGBA with color channels premultiplied by alpha (the format the blend loops naturally produce). GPU pipelines that expect premultiplied textures avoid a full-buffer extra pass this way; the output then DIFFERS from the C twin's straight-alpha format.

Source
rasterize(image : Image, tx : Float32, ty : Float32, scale : Float32, w : Int32, h : Int32, premultiplied : Bool = false) : Bytes

Convenience overload: allocates an RGBA buffer of wh4 (stride = w*4) and returns it (non-premultiplied alpha unless premultiplied: true).

Source