Sign in

    mizchi/crater-painter/x/image does not have a README file

    ClipRect

    pub(all) struct ClipRect {
    x : Int
    y : Int
    w : Int
    h : Int
    }

    Clip rectangle for overflow clipping. None means no clipping (full framebuffer).

    Color

    pub(all) struct Color {
    r : Int
    g : Int
    b : Int
    }

    RGB Color (0-255 range)

    Color::black

    fn Color::black() -> Color

    Color::blend

    fn Color::blend(self : Color, bg : Color, alpha : Int) -> Color

    Blend color with alpha (0-255)

    Color::blue

    fn Color::blue() -> Color

    Color::gray

    fn Color::gray() -> Color

    Color::green

    fn Color::green() -> Color

    Color::red

    fn Color::red() -> Color

    Color::transparent

    fn Color::transparent() -> Color

    Predefined colors for visualization

    Color::white

    fn Color::white() -> Color

    Color::yellow

    fn Color::yellow() -> Color

    DynamicPalette

    pub struct DynamicPalette {
    colors : Array[Color]
    color_map : Map[Int, Int]
    }

    Dynamic color palette that builds from PaintNode colors

    DynamicPalette::new

    Framebuffer

    pub struct Framebuffer {
    width : Int
    height : Int
    pixels : Array[Int]
    }

    Simple framebuffer for rendering

    Framebuffer::draw_char

    fn Framebuffer::draw_char(self : Framebuffer, x : Int, y : Int, c : Char, color : Int, scale : Int) -> Int

    Draw a single character at the given position using bitmap font Returns the width of the character drawn (in pixels)

    Framebuffer::draw_text

    fn Framebuffer::draw_text(self : Framebuffer, x : Int, y : Int, text : String, max_width : Int, color : Int, scale : Int) -> Int

    Draw text string at the given position Handles line wrapping within the given width constraint Returns the height of the text drawn (in pixels)

    Framebuffer::fill_rect

    fn Framebuffer::fill_rect(self : Framebuffer, x : Int, y : Int, w : Int, h : Int, color : Int) -> Unit

    Draw a filled rectangle

    Framebuffer::fill_rect_hatched

    fn Framebuffer::fill_rect_hatched(self : Framebuffer, x : Int, y : Int, w : Int, h : Int, bg_color : Int, line_color : Int, spacing : Int) -> Unit

    Draw a filled rectangle with diagonal hatching pattern spacing: pixels between diagonal lines (e.g., 4)

    Framebuffer::get_pixel

    fn Framebuffer::get_pixel(self : Framebuffer, x : Int, y : Int) -> Int

    Framebuffer::new

    fn Framebuffer::new(width : Int, height : Int) -> Framebuffer

    Framebuffer::stroke_rect

    fn Framebuffer::stroke_rect(self : Framebuffer, x : Int, y : Int, w : Int, h : Int, color : Int) -> Unit

    Draw a rectangle outline

    GlyphProvider

    pub(all) struct GlyphProvider {
    get_glyph : (Int, Double, Bool) -> (Array[
    PathCommand
    ], Double)
    get_kern : (Int, Int, Double, Bool) -> Double
    ascent_ratio : Double
    get_glyph_for_family : (Int, Double, Bool, String) -> (Array[
    PathCommand
    ], Double)??
    get_kern_for_family : (Int, Int, Double, Bool, String) -> Double?
    get_ascent_for_family : (String) -> Double?
    }

    Provides glyph outlines and advance widths for text rendering.

    ImageProvider

    pub(all) struct ImageProvider {
    resolve : (String) -> ResolvedImage?
    }

    RasterImage

    pub(all) struct RasterImage {
    width : Int
    height : Int
    rgba : Array[Int]
    }

    ResolvedImage

    pub(all) enum ResolvedImage {
    Raster(RasterImage)
    Svg(String)
    }

    clear_glyph_provider

    fn clear_glyph_provider() -> Unit

    clear_image_provider

    fn clear_image_provider() -> Unit

    create_svg_demo_scene

    fn create_svg_demo_scene() ->
    Scene

    Create a simple SVG demo scene

    font_height

    let font_height : Int

    font_width

    let font_width : Int

    Font dimensions

    framebuffer_to_rgba_base64

    fn framebuffer_to_rgba_base64(fb : Framebuffer, palette : DynamicPalette) -> String

    get_char_bitmap

    fn get_char_bitmap(c : Char) -> Array[Int]?

    Get bitmap data for an ASCII character Returns array of 16 bytes, each byte is one row (MSB = leftmost pixel) Returns None for unsupported characters

    get_depth_color

    fn get_depth_color(depth : Int) -> Color

    Get color by depth level

    glyph_provider_from_bytes

    fn glyph_provider_from_bytes(data : Bytes) -> GlyphProvider?

    Parse font bytes and create a GlyphProvider. Returns None if font parsing fails.

    glyph_provider_from_font

    fn glyph_provider_from_font(font :
    TTFont
    ) -> GlyphProvider

    Create a GlyphProvider from a parsed TTFont. This allows native text rendering without JS FFI.

    is_font_supported

    fn is_font_supported(c : Char) -> Bool

    Check if character is supported by the bitmap font

    pre_rasterize_glyphs

    fn pre_rasterize_glyphs(font_sizes : Array[Double], font_family? : String) -> Int

    Pre-rasterize common ASCII glyphs at given font sizes. Call after set_glyph_provider to warm the bitmap cache.
    fn print_layout(layout :
    Layout
    , width : Int, height : Int) -> Unit

    Simple print function that outputs sixel to stdout

    render_layout

    fn render_layout(layout :
    Layout
    , width : Int, height : Int) -> String

    Render layout tree to Sixel string

    render_layout_with_options

    fn render_layout_with_options(layout :
    Layout
    , width : Int, height : Int, show_box_model : Bool) -> String

    Render layout tree to Sixel string with options

    render_paint_node_to_framebuffer

    fn render_paint_node_to_framebuffer(node :
    PaintNode
    , fb : Framebuffer, palette : DynamicPalette) -> Unit

    Render PaintNode tree to framebuffer (for use by other renderers like Kitty)

    render_paint_node_to_framebuffer_scrolled

    fn render_paint_node_to_framebuffer_scrolled(node :
    PaintNode
    , fb : Framebuffer, palette : DynamicPalette, scroll_y : Int) -> Unit

    Render PaintNode tree to framebuffer with scroll offset

    render_paint_node_to_sixel

    fn render_paint_node_to_sixel(node :
    PaintNode
    , width : Int, height : Int) -> String

    Render PaintNode tree to Sixel string with actual CSS colors

    render_paint_node_to_sixel_scrolled

    fn render_paint_node_to_sixel_scrolled(node :
    PaintNode
    , width : Int, height : Int, scroll_y : Int) -> String

    Render PaintNode tree to Sixel string with scroll offset

    render_svg_node_to_sixel

    fn render_svg_node_to_sixel(node :
    SVGNode
    , width : Int, height : Int) -> String

    Render an SVGNode directly to Sixel string

    render_svg_path_to_sixel

    fn render_svg_path_to_sixel(path_data : String, fill_color : Color?, stroke_color : Color?, width : Int, height : Int) -> String

    Render an SVG path string to Sixel string

    render_svg_scene

    fn render_svg_scene(scene :
    Scene
    , fb : Framebuffer, palette : DynamicPalette) -> Unit

    Render an SVG scene to a Framebuffer

    render_svg_scene_with_camera

    fn render_svg_scene_with_camera(scene :
    Scene
    , fb : Framebuffer, palette : DynamicPalette, camera :
    Camera
    ) -> Unit

    Render an SVG scene with camera to a Framebuffer

    render_svg_to_sixel

    fn render_svg_to_sixel(scene :
    Scene
    , width : Int, height : Int) -> String

    Render an SVG scene to Sixel string

    render_svg_to_sixel_with_camera

    fn render_svg_to_sixel_with_camera(scene :
    Scene
    , camera :
    Camera
    ) -> String

    Render an SVG scene with camera to Sixel string

    render_with_styles

    fn render_with_styles(node :
    Node
    , layout :
    Layout
    , width : Int, height : Int) -> String

    Render Node + Layout to Sixel string with CSS colors

    render_with_styles_scrolled

    fn render_with_styles_scrolled(node :
    Node
    , layout :
    Layout
    , width : Int, height : Int, scroll_y : Int) -> String

    Render Node + Layout to Sixel string with CSS colors and scroll offset

    set_glyph_provider

    fn set_glyph_provider(provider : GlyphProvider) -> Unit

    set_image_provider

    fn set_image_provider(provider : ImageProvider) -> Unit

    to_sixel

    fn to_sixel(fb : Framebuffer) -> String

    Convert framebuffer to Sixel string

    to_sixel_dynamic

    fn to_sixel_dynamic(fb : Framebuffer, palette : DynamicPalette) -> String

    Convert framebuffer to Sixel string with dynamic palette

    to_sixel_extended

    fn to_sixel_extended(fb : Framebuffer) -> String

    Convert framebuffer to Sixel string with extended palette

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io