Skip to documentation
SLOP

tiny.filigree.render

Reference tiny.filigree render

Defined in tiny.filigree.

API (11)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callstiny.filigreerender
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/filigree/src/render/canvas.zig:11

zig
pub const Canvas = struct {    pixels: []u8,    width: usize,    height: usize,    stride: usize,    pub fn init(pixels: []u8, width: usize, height: usize, stride: usize) !Canvas {        if (width == 0 or height == 0) return error.InvalidCanvas;        const row_bytes = try std.math.mul(usize, width, 4);        if (stride < row_bytes) return error.InvalidCanvas;        const required = try std.math.add(            usize,            try std.math.mul(usize, stride, height - 1),            row_bytes,        );        if (pixels.len < required) return error.InvalidCanvas;        return .{            .pixels = pixels,            .width = width,            .height = height,            .stride = stride,        };    }    fn blend(self: Canvas, x: i32, y: i32, color: Color, coverage: u8) void {        if (coverage == 0 or color.a == 0) return;        if (x < 0 or y < 0) return;        const ux: usize = @intCast(x);        const uy: usize = @intCast(y);        if (ux >= self.width or uy >= self.height) return;        const src_a: u32 = (@as(u32, coverage) * @as(u32, color.a) + 127) / 255;        if (src_a == 0) return;        const offset = uy * self.stride + ux * 4;        const dst_a: u32 = self.pixels[offset + 3];        const inv_src_a: u32 = 255 - src_a;        const out_a: u32 = src_a + (dst_a * inv_src_a) / 255;        if (out_a == 0) {            self.pixels[offset] = 0;            self.pixels[offset + 1] = 0;            self.pixels[offset + 2] = 0;            self.pixels[offset + 3] = 0;            return;        }        self.pixels[offset] = blendChannel(color.r, self.pixels[offset], src_a, dst_a, inv_src_a, out_a);        self.pixels[offset + 1] = blendChannel(color.g, self.pixels[offset + 1], src_a, dst_a, inv_src_a, out_a);        self.pixels[offset + 2] = blendChannel(color.b, self.pixels[offset + 2], src_a, dst_a, inv_src_a, out_a);        self.pixels[offset + 3] = @intCast(@min(out_a, 255));    }};

Source: lib/filigree/src/render/canvas.zig:4

zig
pub const Color = struct {    r: u8 = 255,    g: u8 = 255,    b: u8 = 255,    a: u8 = 255,};

Source: lib/filigree/src/render/text.zig:10

zig
pub const DrawOptions = struct {    color: Color = .{},};

Source: lib/filigree/src/render/text.zig:14

zig
pub const Metrics = struct {    advance_x: i32,    advance_y: i32,};

Source: lib/filigree/src/render/root.zig

zig
const canvas = @import("canvas.zig");const text = @import("text.zig");pub const Color = canvas.Color;pub const Canvas = canvas.Canvas;pub const DrawOptions = text.DrawOptions;pub const Metrics = text.Metrics;pub const drawFallbackUtf8 = text.drawFallbackUtf8;pub const drawGlyphRun = text.drawGlyphRun;pub const drawUtf8 = text.drawUtf8;pub const measureFallbackUtf8 = text.measureFallbackUtf8;pub const measureGlyphRun = text.measureGlyphRun;pub const measureUtf8 = text.measureUtf8;

Source: lib/filigree/src/root.zig:14

zig
pub const render = @import("render/root.zig");

Audit

Definitions6
Public names6
Members11
Version26.7.0
Revisiondaab053ee433