tycho_2d

    Tycho 2D — Skia/Impeller-inspired pure-MoonBit 2D vector, SDF, atlas, text, and compositing engine over laplaceliu/tycho

    2d
    graphics
    sdf
    ui
    skia
    tycho
    Download zip
    Version
    0.10.1
    License
    Apache-2.0
    Last updated
    2 days ago
    Downloads
    61

    #laplaceliu/tycho_2d

    Skia / Impeller-inspired pure-MoonBit 2D vector, text, and compositing graphics engine built on laplaceliu/tycho and laplaceliu/tycho_math.

    #Highlights

    • Canvas & DisplayList: Declarative Canvas (save/restore, save_layer, save_backdrop_layer, transforms, clipping) recording immutable DisplayLists, plus paired helpers with_save(fn) / with_layer(fn) so scopes cannot leak a missing restore().
    • Scoped passes: every self-contained pass records through cmd.render_pass(…) / cmd.swapchain_pass(…) (downsample, blur H/V, MSAA resolve, batched path flush, present). The frame pass is the one exception: draw_path_gpu suspends it to render an offscreen effect and begin_target_pass resumes it, so that pass keeps the explicit begin_render_pass / end_render_pass pair.
    • Ergonomic API: every optional argument uses native MoonBit optional parameters (shader? : Shader2D, bounds? : Rect, fallback? : FontFallbackChain, …), Image2D::from_bytes(w, h, pixels) allocates its own cache id, BoxShadow::new(color, dx=…, dy=…, blur=…, spread=…) replaces the anonymous float shadow arguments, and both render entries take the target first: render_offscreen(target, dl) / render_swapchain(sc, dl).
    • Offscreen Target First: Renderer2D::render_offscreen(target, display_list, …) and Renderer2D::render_swapchain(swapchain, display_list, …) share one argument order.
    • Tier-1 SDF & Atlas Batching: Instanced per-corner rounded rectangles, borders, analytical drop shadows, multi-stop linear/radial/sweep gradients, R8 glyph & RGBA8 image atlases (SkylinePacker).
    • Tier-2 Vector Paths: Adaptive Bézier flattening, Depth24Stencil8 Stencil-then-Cover (NonZero & EvenOdd), and Butt/Round/Square + Miter/Round/Bevel stroke expansion.
    • Overlay Composition: render_swapchain(..., load_op=Load) and render_swapchain_pass(cmd, sc, dl) draw a display list over an existing swapchain image (e.g. a 3D frame) with premultiplied blending, enabling 3D + HUD composition without an intermediate copy.
    • Tier-3 Layers & Blur: Pooled offscreen RenderTargetPool for group opacity, blend modes (SrcOver, Multiply, DstIn, SrcIn), and Gaussian BackdropFilter blur.
    • Pure-MoonBit Text: Built-in fallback font + TrueType .ttf parser & scanline AA rasterizer + Paragraph layout (get_position_for_offset, get_caret_rect, get_boxes_for_range).
    • Zero Runtime Shader Compiler Dependency: AOT embedded SPIR-V (shaders_spv.mbt) and zero .c stubs or cc-link-flags.
    • Shared math kernel: scalar/trigonometry helpers (clamp_f, lerp_f, sin_cos, atan2) come from laplaceliu/tycho_math instead of local approximations, and Matrix3 converts losslessly to/from Affine2 (to_affine2 / from_affine2) so a 2D UI transform can be promoted into a 3D scene.

    RenderTargetPool

    BlendMode2D

    pub(all) enum BlendMode2D {
    SrcOver
    Src
    Dst
    DstOver
    SrcIn
    DstIn
    SrcOut
    DstOut
    SrcAtop
    DstAtop
    Xor
    Plus
    Multiply
    Screen
    Darken
    Lighten
    Clear
    } derive(Eq,
    Debug
    )

    BlendMode2D::to_blend_state

    BlendMode2D::to_rhi

    BoxShadow

    pub(all) struct BoxShadow {
    dx : Float
    dy : Float
    blur : Float
    spread : Float
    color : Color
    }

    BoxShadow::new

    fn BoxShadow::new(color : Color, dx? : Float, dy? : Float, blur? : Float, spread? : Float) -> BoxShadow

    Canvas

    pub struct Canvas {
    // private fields
    }

    Canvas::clear

    fn Canvas::clear(self : Canvas, color : Color) -> Unit

    Canvas::clip_path

    fn Canvas::clip_path(self : Canvas, path : Path, op? : ClipOp) -> Unit

    Canvas::clip_rect

    fn Canvas::clip_rect(self : Canvas, rect : Rect, op? : ClipOp) -> Unit

    Canvas::clip_rrect

    fn Canvas::clip_rrect(self : Canvas, rrect : RRect, op? : ClipOp) -> Unit

    Canvas::concat

    fn Canvas::concat(self : Canvas, mat : Matrix3) -> Unit

    Canvas::draw_arc

    fn Canvas::draw_arc(self : Canvas, rect : Rect, start_degrees : Float, sweep_degrees : Float, paint : Paint) -> Unit

    Canvas::draw_atlas

    fn Canvas::draw_atlas(self : Canvas, image : Image2D, entries : Array[(Rect, Rect)], paint? : Paint) -> Unit

    Canvas::draw_circle

    fn Canvas::draw_circle(self : Canvas, center : Point, radius : Float, paint : Paint) -> Unit

    Canvas::draw_dashed_path

    fn Canvas::draw_dashed_path(self : Canvas, path : Path, pattern : Array[Float], phase : Float, paint : Paint) -> Unit

    Canvas::draw_display_list

    fn Canvas::draw_display_list(self : Canvas, dl : DisplayList) -> Unit

    Canvas::draw_drrect

    fn Canvas::draw_drrect(self : Canvas, outer : RRect, inner : RRect, paint : Paint) -> Unit

    Canvas::draw_image

    fn Canvas::draw_image(self : Canvas, image : Image2D, pos : Point, paint? : Paint) -> Unit

    Canvas::draw_image_rect

    fn Canvas::draw_image_rect(self : Canvas, image : Image2D, src : Rect, dst : Rect, paint? : Paint) -> Unit

    Canvas::draw_line

    fn Canvas::draw_line(self : Canvas, p0 : Point, p1 : Point, paint : Paint) -> Unit

    Canvas::draw_nine_patch

    fn Canvas::draw_nine_patch(self : Canvas, image : Image2D, center_src : Rect, dst : Rect, paint? : Paint) -> Unit

    Canvas::draw_oval

    fn Canvas::draw_oval(self : Canvas, rect : Rect, paint : Paint) -> Unit

    Canvas::draw_paragraph

    fn Canvas::draw_paragraph(self : Canvas, paragraph : Paragraph, pos : Point) -> Unit

    Canvas::draw_path

    fn Canvas::draw_path(self : Canvas, path : Path, paint : Paint) -> Unit

    Canvas::draw_path_shadow

    fn Canvas::draw_path_shadow(self : Canvas, path : Path, shadow : BoxShadow) -> Unit

    Canvas::draw_points

    fn Canvas::draw_points(self : Canvas, points : Array[Point], paint : Paint) -> Unit

    Canvas::draw_rect

    fn Canvas::draw_rect(self : Canvas, rect : Rect, paint : Paint) -> Unit

    Canvas::draw_rrect

    fn Canvas::draw_rrect(self : Canvas, rrect : RRect, paint : Paint) -> Unit

    Canvas::draw_rrect_shadow

    fn Canvas::draw_rrect_shadow(self : Canvas, rrect : RRect, shadow : BoxShadow) -> Unit

    Canvas::draw_text_on_path

    fn Canvas::draw_text_on_path(self : Canvas, paragraph : Paragraph, path : Path, paint : Paint, offset? : Float) -> Unit

    Canvas::draw_vertices

    fn Canvas::draw_vertices(self : Canvas, vertices : Array[Vertex2D], indices : Array[Int], paint? : Paint, image? : Image2D) -> Unit

    Canvas::finish

    fn Canvas::finish(self : Canvas) -> DisplayList

    Canvas::new

    fn Canvas::new() -> Canvas

    Canvas::restore

    fn Canvas::restore(self : Canvas) -> Unit

    Canvas::restore_to_count

    fn Canvas::restore_to_count(self : Canvas, target_count : Int) -> Unit

    Canvas::rotate

    fn Canvas::rotate(self : Canvas, radians : Float) -> Unit

    Canvas::save

    fn Canvas::save(self : Canvas) -> Int

    Canvas::save_backdrop_layer

    fn Canvas::save_backdrop_layer(self : Canvas, bounds : Rect, filter : ImageFilter) -> Int

    Canvas::save_count

    fn Canvas::save_count(self : Canvas) -> Int

    Canvas::save_layer

    fn Canvas::save_layer(self : Canvas, bounds? : Rect, paint? : Paint) -> Int

    Canvas::scale

    fn Canvas::scale(self : Canvas, sx : Float, sy : Float) -> Unit

    Canvas::translate

    fn Canvas::translate(self : Canvas, dx : Float, dy : Float) -> Unit

    Canvas::with_layer

    fn Canvas::with_layer(self : Canvas, bounds? : Rect, paint? : Paint, f : (Canvas) -> Unit) -> Unit

    Runs f inside an automatically paired save_layer() / restore().

    Canvas::with_save

    fn Canvas::with_save(self : Canvas, f : (Canvas) -> Unit) -> Unit

    Runs f inside an automatically paired save() / restore().

    ClipOp

    pub(all) enum ClipOp {
    Intersect
    Difference
    } derive(Eq,
    Debug
    )

    Color

    pub(all) struct Color {
    r : Float
    g : Float
    b : Float
    a : Float
    } derive(Eq,
    Debug
    )

    Color::black

    fn Color::black() -> Color

    Color::from_argb32

    fn Color::from_argb32(argb : UInt) -> Color

    Color::from_rgba8

    fn Color::from_rgba8(r : Int, g : Int, b : Int, a? : Int) -> Color

    Color::lerp

    fn Color::lerp(self : Color, other : Color, t : Float) -> Color

    Color::rgb

    fn Color::rgb(r : Float, g : Float, b : Float) -> Color

    Color::rgba

    fn Color::rgba(r : Float, g : Float, b : Float, a : Float) -> Color

    Color::to_clear_color

    fn Color::to_clear_color(self : Color) ->
    ClearColor

    Color::to_premul

    fn Color::to_premul(self : Color) -> (Float, Float, Float, Float)

    Color::transparent

    fn Color::transparent() -> Color

    Color::white

    fn Color::white() -> Color

    Color::with_alpha

    fn Color::with_alpha(self : Color, a : Float) -> Color

    ColorBitmap

    pub(all) struct ColorBitmap {
    width : Int
    height : Int
    bearing_x : Int
    bearing_y : Int
    advance : Int
    ppem : Int
    png : Bytes
    }

    ColorFilter

    pub(all) enum ColorFilter {
    Matrix(FixedArray[Float])
    Blend(Color, BlendMode2D)
    }

    CoverageBitmap

    pub(all) struct CoverageBitmap {
    width : Int
    height : Int
    origin_x : Int
    origin_y : Int
    pixels : Bytes
    }

    DecodedImage

    pub(all) struct DecodedImage {
    width : Int
    height : Int
    rgba : Bytes
    }

    DecodedImage::new

    fn DecodedImage::new(width : Int, height : Int, rgba : Bytes) -> DecodedImage

    DisplayList

    pub struct DisplayList {
    ops : FixedArray[DrawOp]
    bounds : Rect
    }

    DisplayList::bounds

    fn DisplayList::bounds(self : DisplayList) -> Rect

    DisplayList::needs_offscreen

    fn DisplayList::needs_offscreen(self : DisplayList) -> Bool

    DisplayList::op_count

    fn DisplayList::op_count(self : DisplayList) -> Int

    DrawOp

    pub(all) enum DrawOp {
    Clear(Color)
    Save
    Restore
    SaveLayer(Rect?, Paint)
    SaveBackdropLayer(Rect, ImageFilter)
    Concat(Matrix3)
    ClipRect(Rect, ClipOp)
    ClipRRect(RRect, ClipOp)
    ClipPath(Path, ClipOp)
    DrawRect(Rect, Paint)
    DrawRRect(RRect, Paint)
    DrawCircle(Point, Float, Paint)
    DrawLine(Point, Point, Paint)
    DrawRRectShadow(RRect, Float, Float, Float, Float, Color)
    DrawPath(Path, Paint)
    DrawImage(Image2D, Rect, Rect, Paint)
    DrawVertices(Array[Vertex2D], Array[Int], Paint, Image2D?)
    DrawParagraph(Paragraph, Point)
    DrawTextOnPath(Paragraph, Path, Paint, Float)
    DrawDisplayList(DisplayList)
    }

    DynamicAtlas

    pub struct DynamicAtlas {
    texture :
    Texture

    width : Int
    height : Int
    packer : SkylinePacker
    // private fields
    }

    DynamicAtlas::alloc_and_upload

    fn DynamicAtlas::alloc_and_upload(self : DynamicAtlas, w : Int, h : Int, pixels : Bytes, padding? : Int) -> (Int, Int)? raise
    RhiError

    DynamicAtlas::alloc_and_upload_padded

    fn DynamicAtlas::alloc_and_upload_padded(self : DynamicAtlas, w : Int, h : Int, pixels : Bytes, padding? : Int) -> (Int, Int, Int, Int)? raise
    RhiError

    DynamicAtlas::destroy

    fn DynamicAtlas::destroy(self : DynamicAtlas) -> Unit

    DynamicAtlas::flush_uploads

    fn DynamicAtlas::flush_uploads(self : DynamicAtlas) -> Unit raise
    RhiError

    DynamicAtlas::generation

    fn DynamicAtlas::generation(self : DynamicAtlas) -> Int

    DynamicAtlas::reset

    fn DynamicAtlas::reset(self : DynamicAtlas) -> Unit

    DynamicAtlas::uv_rect

    fn DynamicAtlas::uv_rect(self : DynamicAtlas, x : Int, y : Int, w : Int, h : Int) -> (Float, Float, Float, Float)

    FillRule

    pub(all) enum FillRule {
    NonZero
    EvenOdd
    } derive(Eq,
    Debug
    )

    FontFace

    pub struct FontFace {
    // private fields
    }

    FontFace::advance_width

    fn FontFace::advance_width(self : FontFace, cp : Int, size_px : Float) -> Float

    FontFace::arabic_form_gid

    fn FontFace::arabic_form_gid(self : FontFace, cp : Int, form : Int) -> Int?

    FontFace::builtin

    fn FontFace::builtin() -> FontFace

    FontFace::clear_variations

    fn FontFace::clear_variations(self : FontFace) -> Unit

    FontFace::color_bitmap

    fn FontFace::color_bitmap(self : FontFace, cp : Int, size_px : Float) -> ColorBitmap?

    FontFace::color_glyph

    fn FontFace::color_glyph(self : FontFace, cp : Int, size_px : Float, decoder? : (Bytes) -> DecodedImage?) -> (ColorBitmap, DecodedImage)?

    FontFace::from_ttf_bytes

    fn FontFace::from_ttf_bytes(bytes : Bytes) -> FontFace?

    FontFace::glyph_advance

    fn FontFace::glyph_advance(self : FontFace, gid : Int, size_px : Float) -> Float

    FontFace::glyph_id

    fn FontFace::glyph_id(self : FontFace, cp : Int) -> Int

    FontFace::gpos_kern

    fn FontFace::gpos_kern(self : FontFace, g1 : Int, g2 : Int, size_px : Float) -> Float

    FontFace::has_color_bitmap

    fn FontFace::has_color_bitmap(self : FontFace, cp : Int) -> Bool

    FontFace::has_glyph

    fn FontFace::has_glyph(self : FontFace, cp : Int) -> Bool

    FontFace::has_gpos_kern

    fn FontFace::has_gpos_kern(self : FontFace) -> Bool

    FontFace::has_gvar

    fn FontFace::has_gvar(self : FontFace) -> Bool

    FontFace::has_liga

    fn FontFace::has_liga(self : FontFace) -> Bool

    FontFace::id

    fn FontFace::id(self : FontFace) -> Int

    FontFace::india_shape

    fn FontFace::india_shape(self : FontFace, gids : Array[Int], tags : Array[String]) -> Array[(Int, Int)]

    FontFace::kern

    fn FontFace::kern(self : FontFace, cp1 : Int, cp2 : Int, size_px : Float) -> Float

    FontFace::kern_gid

    fn FontFace::kern_gid(self : FontFace, g1 : Int, g2 : Int, size_px : Float) -> Float

    FontFace::ligate_glyphs

    fn FontFace::ligate_glyphs(self : FontFace, gids : Array[Int]) -> Array[(Int, Int)]

    FontFace::metrics

    fn FontFace::metrics(self : FontFace, size_px : Float) -> (Float, Float, Float)

    FontFace::normalized_coord

    fn FontFace::normalized_coord(self : FontFace, tag : String) -> Float

    FontFace::normalized_coords

    fn FontFace::normalized_coords(self : FontFace) -> Array[Float]

    FontFace::rasterize_bitmap

    fn FontFace::rasterize_bitmap(self : FontFace, gid : Int, cp : Int, size_px : Float, bold : Bool, italic : Bool) -> (Int, Int, Int, Int, Bytes)

    FontFace::rlig_ligate

    fn FontFace::rlig_ligate(self : FontFace, gids : Array[Int]) -> Array[(Int, Int)]

    FontFace::set_variation

    fn FontFace::set_variation(self : FontFace, tag : String, value : Float) -> Unit

    FontFace::variation_axes

    fn FontFace::variation_axes(self : FontFace) -> Array[FontVariationAxis]

    FontFace::variation_value

    fn FontFace::variation_value(self : FontFace, tag : String) -> Float

    FontFallbackChain

    pub(all) struct FontFallbackChain {
    // private fields
    }

    FontFallbackChain::face_for

    fn FontFallbackChain::face_for(self : FontFallbackChain, cp : Int) -> FontFace

    FontFallbackChain::faces

    FontFallbackChain::new

    fn FontFallbackChain::new(primary : FontFace, fallbacks? : Array[FontFace]) -> FontFallbackChain

    FontVariationAxis

    pub(all) struct FontVariationAxis {
    tag : String
    min_value : Float
    default_value : Float
    max_value : Float
    }

    GlyphCache

    pub struct GlyphCache {
    atlas : DynamicAtlas
    msdf_atlas : DynamicAtlas
    // private fields
    }

    GlyphCache::alloc_coverage

    fn GlyphCache::alloc_coverage(self : GlyphCache, w : Int, h : Int, pixels : Bytes) -> (Float, Float, Float, Float)? raise
    RhiError

    GlyphCache::atlas_overflow_count

    fn GlyphCache::atlas_overflow_count(self : GlyphCache) -> Int

    GlyphCache::atlas_reset_count

    fn GlyphCache::atlas_reset_count(self : GlyphCache) -> Int

    GlyphCache::atlas_size

    fn GlyphCache::atlas_size(self : GlyphCache) -> (Int, Int)

    GlyphCache::begin_frame

    fn GlyphCache::begin_frame(self : GlyphCache, frame : Int) -> Unit

    GlyphCache::destroy

    fn GlyphCache::destroy(self : GlyphCache) -> Unit

    GlyphCache::entry_count

    fn GlyphCache::entry_count(self : GlyphCache) -> Int

    GlyphCache::generation

    fn GlyphCache::generation(self : GlyphCache) -> Int

    GlyphCache::get_or_rasterize

    fn GlyphCache::get_or_rasterize(self : GlyphCache, font : FontFace, cp : Int, size_px : Float) -> GlyphEntry raise
    RhiError

    GlyphCache::get_or_rasterize_gid

    fn GlyphCache::get_or_rasterize_gid(self : GlyphCache, font : FontFace, gid : Int, cp : Int, size_px : Float) -> GlyphEntry raise
    RhiError

    GlyphCache::get_or_rasterize_styled

    fn GlyphCache::get_or_rasterize_styled(self : GlyphCache, font : FontFace, gid : Int, cp : Int, size_px : Float, bold : Bool, italic : Bool) -> GlyphEntry raise
    RhiError

    GlyphCache::msdf_count

    fn GlyphCache::msdf_count(self : GlyphCache) -> Int

    GlyphCache::new

    fn GlyphCache::new(dev :
    Device
    , width? : Int, height? : Int) -> GlyphCache raise
    RhiError

    GlyphCache::sdf_count

    fn GlyphCache::sdf_count(self : GlyphCache) -> Int

    GlyphCache::set_msdf_enabled

    fn GlyphCache::set_msdf_enabled(self : GlyphCache, enabled : Bool) -> Unit

    GlyphCache::set_msdf_min_size

    fn GlyphCache::set_msdf_min_size(self : GlyphCache, size : Float) -> Unit

    GlyphEntry

    pub(all) struct GlyphEntry {
    uv_x0 : Float
    uv_y0 : Float
    uv_x1 : Float
    uv_y1 : Float
    offset_x : Int
    offset_y : Int
    width : Int
    height : Int
    advance : Float
    is_sdf : Bool
    sdf_base : Float
    is_msdf : Bool
    }

    GradientStop

    pub(all) struct GradientStop {
    offset : Float
    color : Color
    } derive(Eq,
    Debug
    )

    GradientStop::new

    fn GradientStop::new(offset : Float, color : Color) -> GradientStop

    Image2D

    pub(all) struct Image2D {
    width : Int
    height : Int
    pixels : Bytes
    texture :
    Texture
    ?
    srgb : Bool
    premultiplied : Bool
    // private fields
    }

    Image2D::from_bytes

    fn Image2D::from_bytes(width : Int, height : Int, pixels : Bytes, srgb? : Bool, premultiplied? : Bool) -> Image2D

    Image2D::from_texture

    fn Image2D::from_texture(texture :
    Texture
    ) -> Image2D

    Image2D::id

    fn Image2D::id(self : Image2D) -> Int

    Renderer-side cache key. Unique per handle, allocated on construction.

    ImageFilter

    pub(all) enum ImageFilter {
    Blur(Float, Float, TileMode)
    DropShadow(Float, Float, Float, Float, Color)
    ColorMatrix(FixedArray[Float])
    }

    LineMetrics

    pub(all) struct LineMetrics {
    start_index : Int
    end_index : Int
    y : Float
    height : Float
    baseline : Float
    width : Float
    }

    MaskFilter

    pub(all) enum MaskFilter {
    Blur(Float, Float)
    }

    Matrix3

    pub(all) struct Matrix3 {
    a : Float
    c : Float
    tx : Float
    b : Float
    d : Float
    ty : Float
    } derive(Eq,
    Debug
    )

    Matrix3::concat

    fn Matrix3::concat(self : Matrix3, other : Matrix3) -> Matrix3

    Matrix3::from_affine2

    Matrix3::identity

    fn Matrix3::identity() -> Matrix3

    Matrix3::invert

    fn Matrix3::invert(self : Matrix3) -> Matrix3?

    Matrix3::is_axis_aligned

    fn Matrix3::is_axis_aligned(self : Matrix3) -> Bool

    Matrix3::is_pure_translation

    fn Matrix3::is_pure_translation(self : Matrix3) -> Bool

    Matrix3::map_point

    fn Matrix3::map_point(self : Matrix3, pt : Point) -> Point

    Matrix3::map_rect

    fn Matrix3::map_rect(self : Matrix3, rect : Rect) -> Rect

    Matrix3::rotate

    fn Matrix3::rotate(radians : Float) -> Matrix3

    Matrix3::scale

    fn Matrix3::scale(sx : Float, sy : Float) -> Matrix3

    Matrix3::to_affine2

    Convert to the unified 2D affine type from laplaceliu/tycho_math, e.g. to promote a UI transform into a 3D scene with Affine2::to_mat4().

    Matrix3::translate

    fn Matrix3::translate(dx : Float, dy : Float) -> Matrix3

    Paint

    pub(all) struct Paint {
    color : Color
    style : PaintStyle
    stroke_width : Float
    stroke_cap : StrokeCap
    stroke_join : StrokeJoin
    stroke_miter : Float
    blend_mode : BlendMode2D
    shader : Shader2D?
    image_filter : ImageFilter?
    color_filter : ColorFilter?
    mask_filter : MaskFilter?
    anti_alias : Bool
    }

    Paint::fill

    fn Paint::fill(color : Color) -> Paint

    Paint::new

    fn Paint::new(color? : Color, style? : PaintStyle, stroke_width? : Float, stroke_cap? : StrokeCap, stroke_join? : StrokeJoin, stroke_miter? : Float, blend_mode? : BlendMode2D, shader? : Shader2D, image_filter? : ImageFilter, color_filter? : ColorFilter, mask_filter? : MaskFilter, anti_alias? : Bool) -> Paint

    Paint::stroke

    fn Paint::stroke(color : Color, width : Float, cap? : StrokeCap, join? : StrokeJoin) -> Paint

    PaintStyle

    pub(all) enum PaintStyle {
    Fill
    Stroke
    StrokeAndFill
    } derive(Eq,
    Debug
    )

    Paragraph

    pub struct Paragraph {
    // private fields
    }

    Paragraph::get_boxes_for_range

    fn Paragraph::get_boxes_for_range(self : Paragraph, start : Int, end : Int) -> Array[Rect]

    Paragraph::get_caret_rect

    fn Paragraph::get_caret_rect(self : Paragraph, pos : TextPosition) -> Rect

    Paragraph::get_position_for_offset

    fn Paragraph::get_position_for_offset(self : Paragraph, pt : Point) -> TextPosition

    Paragraph::height

    fn Paragraph::height(self : Paragraph) -> Float

    Paragraph::layout

    fn Paragraph::layout(self : Paragraph, max_width : Float) -> Unit

    Paragraph::line_count

    fn Paragraph::line_count(self : Paragraph) -> Int

    Paragraph::line_metrics

    fn Paragraph::line_metrics(self : Paragraph) -> Array[LineMetrics]

    Paragraph::placed_glyphs

    fn Paragraph::placed_glyphs(self : Paragraph) -> Array[PlacedGlyph]

    Paragraph::underline_rects

    fn Paragraph::underline_rects(self : Paragraph) -> Array[(Float, Float, Float, Float, Color)]

    Paragraph::width

    fn Paragraph::width(self : Paragraph) -> Float

    ParagraphBuilder

    pub struct ParagraphBuilder {
    // private fields
    }

    ParagraphBuilder::add_inline_image

    fn ParagraphBuilder::add_inline_image(self : ParagraphBuilder, image : Image2D, width : Float, height : Float, style? : TextStyle) -> ParagraphBuilder

    ParagraphBuilder::add_span

    ParagraphBuilder::add_text

    fn ParagraphBuilder::add_text(self : ParagraphBuilder, text : String, style? : TextStyle) -> ParagraphBuilder

    ParagraphBuilder::build

    ParagraphBuilder::new

    ParagraphStyle

    pub(all) struct ParagraphStyle {
    align : TextAlign
    max_lines : Int
    ellipsis : String
    line_height_scale : Float
    }

    ParagraphStyle::new

    fn ParagraphStyle::new(align? : TextAlign, max_lines? : Int, ellipsis? : String, line_height_scale? : Float) -> ParagraphStyle

    Path

    pub struct Path {
    // private fields
    }

    Path::bounds

    fn Path::bounds(self : Path) -> Rect

    Path::compute_tight_bounds

    fn Path::compute_tight_bounds(self : Path, tolerance? : Float) -> Rect

    Path::contains

    fn Path::contains(self : Path, x : Float, y : Float, fill_rule? : FillRule) -> Bool

    Path::dashed

    fn Path::dashed(self : Path, pattern : Array[Float], phase? : Float) -> Path

    Path::fill_rule

    fn Path::fill_rule(self : Path) -> FillRule

    Path::id

    fn Path::id(self : Path) -> UInt64

    Path::is_empty

    fn Path::is_empty(self : Path) -> Bool

    Path::measure

    fn Path::measure(self : Path, force_closed? : Bool, tolerance? : Float) -> PathMeasure

    Path::op

    fn Path::op(self : Path, other : Path, op : PathOp) -> Path?

    Path::revision

    fn Path::revision(self : Path) -> Int

    Path::transform

    fn Path::transform(self : Path, m : Matrix3) -> Path

    Path::translated

    fn Path::translated(self : Path, dx : Float, dy : Float) -> Path

    PathBuilder

    pub struct PathBuilder {
    // private fields
    }

    PathBuilder::add_arc

    fn PathBuilder::add_arc(self : PathBuilder, rect : Rect, start_degrees : Float, sweep_degrees : Float) -> PathBuilder

    PathBuilder::add_circle

    fn PathBuilder::add_circle(self : PathBuilder, cx : Float, cy : Float, radius : Float) -> PathBuilder

    PathBuilder::add_oval

    fn PathBuilder::add_oval(self : PathBuilder, r : Rect) -> PathBuilder

    PathBuilder::add_path

    fn PathBuilder::add_path(self : PathBuilder, other : Path) -> PathBuilder

    PathBuilder::add_path_translated

    fn PathBuilder::add_path_translated(self : PathBuilder, other : Path, dx : Float, dy : Float) -> PathBuilder

    PathBuilder::add_rect

    fn PathBuilder::add_rect(self : PathBuilder, r : Rect) -> PathBuilder

    PathBuilder::add_rrect

    fn PathBuilder::add_rrect(self : PathBuilder, rr : RRect) -> PathBuilder

    PathBuilder::arc_to

    fn PathBuilder::arc_to(self : PathBuilder, rect : Rect, start_degrees : Float, sweep_degrees : Float, force_move? : Bool) -> PathBuilder

    PathBuilder::build

    fn PathBuilder::build(self : PathBuilder, fill_rule? : FillRule) -> Path

    PathBuilder::close

    fn PathBuilder::close(self : PathBuilder) -> PathBuilder

    PathBuilder::conic_to

    fn PathBuilder::conic_to(self : PathBuilder, cx : Float, cy : Float, x : Float, y : Float, weight : Float) -> PathBuilder

    PathBuilder::cubic_to

    fn PathBuilder::cubic_to(self : PathBuilder, c1x : Float, c1y : Float, c2x : Float, c2y : Float, x : Float, y : Float) -> PathBuilder

    PathBuilder::current_point

    fn PathBuilder::current_point(self : PathBuilder) -> Point?

    PathBuilder::line_to

    fn PathBuilder::line_to(self : PathBuilder, x : Float, y : Float) -> PathBuilder

    PathBuilder::move_to

    fn PathBuilder::move_to(self : PathBuilder, x : Float, y : Float) -> PathBuilder

    PathBuilder::new

    PathBuilder::quad_to

    fn PathBuilder::quad_to(self : PathBuilder, cx : Float, cy : Float, x : Float, y : Float) -> PathBuilder

    PathMeasure

    pub struct PathMeasure {
    // private fields
    }

    PathMeasure::length

    fn PathMeasure::length(self : PathMeasure) -> Float

    PathMeasure::new

    fn PathMeasure::new(path : Path, force_closed? : Bool, tolerance? : Float) -> PathMeasure

    PathMeasure::pos_at

    fn PathMeasure::pos_at(self : PathMeasure, distance : Float) -> (Point, Point)?

    PathMeasure::segment

    fn PathMeasure::segment(self : PathMeasure, start : Float, stop : Float) -> Path

    PathOp

    pub(all) enum PathOp {
    Union
    Intersect
    Difference
    Xor
    } derive(Eq,
    Debug
    )

    PathVerb

    pub(all) enum PathVerb {
    Move
    Line
    Quad
    Cubic
    Close
    } derive(Eq,
    Debug
    )

    PlacedGlyph

    pub(all) struct PlacedGlyph {
    codepoint : Int
    glyph_id : Int
    font : FontFace
    font_size : Float
    x : Float
    baseline_y : Float
    advance : Float
    color : Color
    char_index : Int
    bold : Bool
    italic : Bool
    image : Image2D?
    image_w : Float
    image_h : Float
    }

    Point

    pub(all) struct Point {
    x : Float
    y : Float
    } derive(Eq,
    Debug
    )

    Point::add

    fn Point::add(self : Point, other : Point) -> Point

    Point::distance_to

    fn Point::distance_to(self : Point, other : Point) -> Float

    Point::lerp

    fn Point::lerp(self : Point, other : Point, t : Float) -> Point

    Point::new

    fn Point::new(x : Float, y : Float) -> Point

    Point::scale

    fn Point::scale(self : Point, s : Float) -> Point

    Point::sub

    fn Point::sub(self : Point, other : Point) -> Point

    Point::zero

    fn Point::zero() -> Point

    RRect

    pub(all) struct RRect {
    rect : Rect
    tl : Float
    tl_y : Float
    tr : Float
    tr_y : Float
    br : Float
    br_y : Float
    bl : Float
    bl_y : Float
    } derive(Eq,
    Debug
    )

    RRect::from_rect

    fn RRect::from_rect(rect : Rect) -> RRect

    RRect::is_circular

    fn RRect::is_circular(self : RRect) -> Bool

    RRect::is_rect

    fn RRect::is_rect(self : RRect) -> Bool

    RRect::offset

    fn RRect::offset(self : RRect, dx : Float, dy : Float) -> RRect

    RRect::per_corner

    fn RRect::per_corner(rect : Rect, tl : Float, tr : Float, br : Float, bl : Float) -> RRect

    RRect::per_corner_xy

    fn RRect::per_corner_xy(rect : Rect, tl_x : Float, tl_y : Float, tr_x : Float, tr_y : Float, br_x : Float, br_y : Float, bl_x : Float, bl_y : Float) -> RRect

    RRect::uniform

    fn RRect::uniform(rect : Rect, radius : Float) -> RRect

    Rect

    pub(all) struct Rect {
    x : Float
    y : Float
    width : Float
    height : Float
    } derive(Eq,
    Debug
    )

    Rect::bottom

    fn Rect::bottom(self : Rect) -> Float

    Rect::center

    fn Rect::center(self : Rect) -> Point

    Rect::contains

    fn Rect::contains(self : Rect, pt : Point) -> Bool

    Rect::from_ltrb

    fn Rect::from_ltrb(l : Float, t : Float, r : Float, b : Float) -> Rect

    Rect::from_size

    fn Rect::from_size(size : Size) -> Rect

    Rect::inflate

    fn Rect::inflate(self : Rect, delta : Float) -> Rect

    Rect::inset

    fn Rect::inset(self : Rect, dx : Float, dy : Float) -> Rect

    Rect::intersect

    fn Rect::intersect(self : Rect, other : Rect) -> Rect

    Rect::is_empty

    fn Rect::is_empty(self : Rect) -> Bool

    Rect::new

    fn Rect::new(x : Float, y : Float, width : Float, height : Float) -> Rect

    Rect::offset

    fn Rect::offset(self : Rect, dx : Float, dy : Float) -> Rect

    Rect::right

    fn Rect::right(self : Rect) -> Float

    Rect::union

    fn Rect::union(self : Rect, other : Rect) -> Rect

    Rect::zero

    fn Rect::zero() -> Rect

    RenderStats

    pub(all) struct RenderStats {
    draw_calls : Int
    path_passes : Int
    prims : Int
    upload_bytes : Int
    glyph_entries : Int
    image_entries : Int
    atlas_resets : Int
    atlas_overflows : Int
    coverage_draws : Int
    coverage_entries : Int
    sdf_glyphs : Int
    msdf_glyphs : Int
    }

    RenderStats::summary

    fn RenderStats::summary(self : RenderStats) -> String

    RenderStats::to_json

    fn RenderStats::to_json(self : RenderStats) -> String

    Renderer2D

    pub struct Renderer2D {
    // private fields
    }

    Renderer2D::dedicated_image_count

    fn Renderer2D::dedicated_image_count(self : Renderer2D) -> Int

    Renderer2D::destroy

    fn Renderer2D::destroy(self : Renderer2D) -> Unit

    Renderer2D::new

    fn Renderer2D::new(dev :
    Device
    , max_prims_per_frame? : Int, max_stops_per_frame? : Int, max_path_verts_per_frame? : Int) -> Renderer2D raise
    RhiError

    Renderer2D::path_batch_count

    fn Renderer2D::path_batch_count(self : Renderer2D) -> Int

    Renderer2D::prim_draw_count

    fn Renderer2D::prim_draw_count(self : Renderer2D) -> Int

    Renderer2D::render_offscreen

    fn Renderer2D::render_offscreen(self : Renderer2D, target :
    Texture
    , dl : DisplayList, clear_color? : Color, damage? : Rect, load_op? :
    LoadOp
    ) -> Unit raise
    RhiError

    Renderer2D::render_swapchain

    fn Renderer2D::render_swapchain(self : Renderer2D, sc :
    Swapchain
    , dl : DisplayList, clear_color? : Color, dl_size? : (Int, Int), load_op? :
    LoadOp
    ) -> Unit raise
    RhiError

    Renderer2D::render_swapchain_pass

    fn Renderer2D::render_swapchain_pass(self : Renderer2D, cmd :
    CommandBuffer
    , sc :
    Swapchain
    , dl : DisplayList, clear_color? : Color, load_op? :
    LoadOp
    , dl_size? : (Int, Int)) -> Unit raise
    RhiError

    Draw dl over an already-open swapchain frame, e.g. after Renderer3D::render_swapchain_into. It neither acquires nor presents: the caller must invoke Swapchain::end_frame with the same command buffer. Defaults to Load with a transparent clear so the 3D image survives.

    Renderer2D::set_coverage_enabled

    fn Renderer2D::set_coverage_enabled(self : Renderer2D, enabled : Bool) -> Unit

    Renderer2D::set_msdf_enabled

    fn Renderer2D::set_msdf_enabled(self : Renderer2D, enabled : Bool) -> Unit

    Renderer2D::set_msdf_min_size

    fn Renderer2D::set_msdf_min_size(self : Renderer2D, size : Float) -> Unit

    Renderer2D::set_png_decoder

    fn Renderer2D::set_png_decoder(self : Renderer2D, decoder : (Bytes) -> DecodedImage?) -> Unit

    Install the PNG decoder used for CBDT colour glyphs (emoji fonts). The decoder lives on the renderer, so separate renderers can decode differently and disposing one cannot break another.

    Renderer2D::stats

    fn Renderer2D::stats(self : Renderer2D) -> RenderStats

    Shader2D

    pub(all) enum Shader2D {
    Solid(Color)
    LinearGradient(Point, Point, Array[GradientStop], TileMode)
    RadialGradient(Point, Float, Array[GradientStop], TileMode)
    SweepGradient(Point, Float, Float, Array[GradientStop], TileMode)
    ImagePattern(Image2D, Matrix3,
    Filter
    , TileMode, TileMode)
    }

    Size

    pub(all) struct Size {
    width : Float
    height : Float
    } derive(Eq,
    Debug
    )

    Size::new

    fn Size::new(width : Float, height : Float) -> Size

    Size::zero

    fn Size::zero() -> Size

    SkylinePacker

    pub struct SkylinePacker {
    width : Int
    height : Int
    // private fields
    }

    SkylinePacker::alloc

    fn SkylinePacker::alloc(self : SkylinePacker, w : Int, h : Int) -> (Int, Int)?

    SkylinePacker::new

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

    SkylinePacker::reset

    fn SkylinePacker::reset(self : SkylinePacker) -> Unit

    SkylinePacker::used_area

    fn SkylinePacker::used_area(self : SkylinePacker) -> Int

    StrokeCap

    pub(all) enum StrokeCap {
    Butt
    Round
    Square
    } derive(Eq,
    Debug
    )

    StrokeJoin

    pub(all) enum StrokeJoin {
    Miter
    Round
    Bevel
    } derive(Eq,
    Debug
    )

    TextAffinity

    pub(all) enum TextAffinity {
    Upstream
    Downstream
    } derive(Eq,
    Debug
    )

    TextAlign

    pub(all) enum TextAlign {
    Left
    Center
    Right
    Justify
    } derive(Eq,
    Debug
    )

    TextPosition

    pub(all) struct TextPosition {
    offset : Int
    line : Int
    affinity : TextAffinity
    } derive(Eq,
    Debug
    )

    TextPosition::new

    fn TextPosition::new(offset : Int, line : Int, affinity? : TextAffinity) -> TextPosition

    TextSpan

    pub(all) struct TextSpan {
    text : String
    style : TextStyle
    image : Image2D?
    image_w : Float
    image_h : Float
    }

    TextSpan::inline_image

    fn TextSpan::inline_image(image : Image2D, width : Float, height : Float, style? : TextStyle) -> TextSpan

    TextSpan::new

    fn TextSpan::new(text : String, style? : TextStyle) -> TextSpan

    TextStyle

    pub(all) struct TextStyle {
    font : FontFace
    font_size : Float
    color : Color
    letter_spacing : Float
    underline : Bool
    bold : Bool
    italic : Bool
    fallback : FontFallbackChain?
    variations : Array[(String, Float)]
    }

    TextStyle::new

    fn TextStyle::new(font? : FontFace, font_size? : Float, color? : Color, letter_spacing? : Float, underline? : Bool, bold? : Bool, italic? : Bool, fallback? : FontFallbackChain, variations? : Array[(String, Float)]) -> TextStyle

    TileMode

    pub(all) enum TileMode {
    Clamp
    Repeat
    Mirror
    Decal
    } derive(Eq,
    Debug
    )

    Vertex2D

    pub(all) struct Vertex2D {
    x : Float
    y : Float
    u : Float
    v : Float
    color : Color
    } derive(Eq,
    Debug
    )

    Vertex2D::new

    fn Vertex2D::new(x : Float, y : Float, u? : Float, v? : Float, color? : Color) -> Vertex2D

    flatten_path_contours

    fn flatten_path_contours(path : Path, xform : Matrix3, tolerance? : Float) -> Array[(Array[Point], Bool)]

    rasterize_coverage

    fn rasterize_coverage(path : Path, xform : Matrix3, fill_rule? : FillRule, tolerance? : Float, max_area? : Int) -> CoverageBitmap?

    tessellate_fill_fan

    fn tessellate_fill_fan(path : Path, xform : Matrix3, tolerance? : Float) -> (Array[Float], Rect)

    tessellate_stroke

    fn tessellate_stroke(path : Path, xform : Matrix3, stroke_width : Float, cap : StrokeCap, join : StrokeJoin, miter_limit : Float, tolerance? : Float) -> Array[Float]