MoonBit bindings for Skia
let context = try! @skia.GlContext()
defer context.dispose()
let surface = try! context.surface(width=640, height=360)
defer surface.dispose()
surface.canvas().clear(@skia.Color(a=255, r=255, g=255, b=255))
try! context.flush()
// The host now swaps its native window buffers.let surface = try! @skia.Surface(width=640, height=360)
defer surface.dispose()
let paint = @skia.Paint()
defer paint.dispose()
let typeface = try! @skia.Typeface::default()
defer typeface.dispose()
let font = try! @skia.Font(typeface, size=32.0)
defer font.dispose()
surface.canvas().draw_text(b"MoonBit + Skia", x=48.0, y=96.0, font, paint)
try! surface.write_png(b"out.png")pub(all) suberror SkiaError {
InvalidPixelBufferSize(width~ : Int, height~ : Int)
InvalidSurfaceSize(width~ : Int, height~ : Int)
TypefaceCreateFailed
FontCreateFailed
GlInterfaceCreateFailed
GlContextCreateFailed
GlContextAbandoned
GlSubmitFailed
PathParseSvgFailed
SurfaceReadPixelsFailed
SurfaceCreateFailed(width~ : Int, height~ : Int)
WritePngFailed(status~ : Int)
} derive(Eq, Debug)pub struct Canvas {
// private fields
}pub struct Color {
a : Byte
r : Byte
g : Byte
b : Byte
}pub struct Font {
// private fields
}pub struct GlContext {
// private fields
}pub struct GlSurface {
// private fields
}pub struct Paint {
// private fields
}pub struct Path {
// private fields
}pub struct PixelBuffer {
data : Bytes
width : Int
height : Int
row_bytes : Int
}pub struct Rect {
left : Float
top : Float
right : Float
bottom : Float
}pub struct Surface {
// private fields
}