Tycho 2D — Skia/Impeller-inspired pure-MoonBit 2D vector, SDF, atlas, text, and compositing engine over laplaceliu/tycho
Part of the Tycho graphics stack — mounted there as the 2d/ submodule.
pub struct Canvas {
// private fields
}pub(all) struct ColorBitmap {
width : Int
height : Int
bearing_x : Int
bearing_y : Int
advance : Int
ppem : Int
png : Bytes
}pub(all) struct CoverageBitmap {
width : Int
height : Int
origin_x : Int
origin_y : Int
pixels : Bytes
}pub(all) struct DecodedImage {
width : Int
height : Int
rgba : Bytes
}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)
}pub struct DynamicAtlas {
texture : Texture
width : Int
height : Int
packer : SkylinePacker
// private fields
}fn DynamicAtlas::alloc_and_upload(self : DynamicAtlas, w : Int, h : Int, pixels : Bytes, padding? : Int) -> (Int, Int)? raise RhiErrorfn DynamicAtlas::alloc_and_upload_padded(self : DynamicAtlas, w : Int, h : Int, pixels : Bytes, padding? : Int) -> (Int, Int, Int, Int)? raise RhiErrorfn DynamicAtlas::new(dev : Device, width : Int, height : Int, format : TextureFormat) -> DynamicAtlas raise RhiErrorfn DynamicAtlas::uv_rect(self : DynamicAtlas, x : Int, y : Int, w : Int, h : Int) -> (Float, Float, Float, Float)pub struct FontFace {
// private fields
}fn FontFace::color_glyph(self : FontFace, cp : Int, size_px : Float, decoder? : (Bytes) -> DecodedImage?) -> (ColorBitmap, DecodedImage)?pub(all) struct FontFallbackChain {
// private fields
}pub(all) struct FontVariationAxis {
tag : String
min_value : Float
default_value : Float
max_value : Float
}fn GlyphCache::alloc_coverage(self : GlyphCache, w : Int, h : Int, pixels : Bytes) -> (Float, Float, Float, Float)? raise RhiErrorfn GlyphCache::get_or_rasterize(self : GlyphCache, font : FontFace, cp : Int, size_px : Float) -> GlyphEntry raise RhiErrorfn GlyphCache::get_or_rasterize_gid(self : GlyphCache, font : FontFace, gid : Int, cp : Int, size_px : Float) -> GlyphEntry raise RhiErrorfn GlyphCache::get_or_rasterize_styled(self : GlyphCache, font : FontFace, gid : Int, cp : Int, size_px : Float, bold : Bool, italic : Bool) -> GlyphEntry raise RhiErrorpub(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
}pub(all) struct Image2D {
width : Int
height : Int
pixels : Bytes
texture : Texture?
srgb : Bool
premultiplied : Bool
// private fields
}pub(all) struct LineMetrics {
start_index : Int
end_index : Int
y : Float
height : Float
baseline : Float
width : Float
}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
}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) -> Paintpub struct Paragraph {
// private fields
}pub struct ParagraphBuilder {
// private fields
}fn ParagraphBuilder::add_inline_image(self : ParagraphBuilder, image : Image2D, width : Float, height : Float, style? : TextStyle) -> ParagraphBuilderfn ParagraphBuilder::add_text(self : ParagraphBuilder, text : String, style? : TextStyle) -> ParagraphBuilderpub(all) struct ParagraphStyle {
align : TextAlign
max_lines : Int
ellipsis : String
line_height_scale : Float
}fn ParagraphStyle::new(align? : TextAlign, max_lines? : Int, ellipsis? : String, line_height_scale? : Float) -> ParagraphStylepub struct Path {
// private fields
}pub struct PathBuilder {
// private fields
}fn PathBuilder::add_arc(self : PathBuilder, rect : Rect, start_degrees : Float, sweep_degrees : Float) -> PathBuilderfn PathBuilder::add_circle(self : PathBuilder, cx : Float, cy : Float, radius : Float) -> PathBuilderfn PathBuilder::add_path_translated(self : PathBuilder, other : Path, dx : Float, dy : Float) -> PathBuilderfn PathBuilder::arc_to(self : PathBuilder, rect : Rect, start_degrees : Float, sweep_degrees : Float, force_move? : Bool) -> PathBuilderfn PathBuilder::conic_to(self : PathBuilder, cx : Float, cy : Float, x : Float, y : Float, weight : Float) -> PathBuilderfn PathBuilder::cubic_to(self : PathBuilder, c1x : Float, c1y : Float, c2x : Float, c2y : Float, x : Float, y : Float) -> PathBuilderfn PathBuilder::quad_to(self : PathBuilder, cx : Float, cy : Float, x : Float, y : Float) -> PathBuilderpub struct PathMeasure {
// private fields
}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
}pub struct Renderer2D {
// private fields
}fn Renderer2D::new(dev : Device, max_prims_per_frame? : Int, max_stops_per_frame? : Int, max_path_verts_per_frame? : Int) -> Renderer2D raise RhiErrorfn Renderer2D::render_offscreen(self : Renderer2D, target : Texture, dl : DisplayList, clear_color? : Color, damage? : Rect, load_op? : LoadOp) -> Unit raise RhiErrorfn Renderer2D::render_swapchain(self : Renderer2D, sc : Swapchain, dl : DisplayList, clear_color? : Color, dl_size? : (Int, Int), load_op? : LoadOp) -> Unit raise RhiErrorfn Renderer2D::render_swapchain_pass(self : Renderer2D, cmd : CommandBuffer, sc : Swapchain, dl : DisplayList, clear_color? : Color, load_op? : LoadOp, dl_size? : (Int, Int)) -> Unit raise RhiErrorpub struct SkylinePacker {
width : Int
height : Int
// private fields
}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)]
}fn rasterize_coverage(path : Path, xform : Matrix3, fill_rule? : FillRule, tolerance? : Float, max_area? : Int) -> CoverageBitmap?fn tessellate_stroke(path : Path, xform : Matrix3, stroke_width : Float, cap : StrokeCap, join : StrokeJoin, miter_limit : Float, tolerance? : Float) -> Array[Float]Install
Download zipTycho 2D — Skia/Impeller-inspired pure-MoonBit 2D vector, SDF, atlas, text, and compositing engine over laplaceliu/tycho