phyron-skia-canvas
v3.6.0
Published
A multi-threaded, GPU-accelerated, Canvas API for Node
Downloads
532
Maintainers
Readme
skia-canvas
GPU-accelerated, multi-threaded HTML Canvas-compatible 2D rendering for Rust and Node.js, powered by Skia.
A fork of samizdatco/skia-canvas that adds:
F16/F32pixel formats for HDR compositing.- Extended color spaces: Display P3, Rec.2020, HDR10 (PQ), HLG, plus linear variants.
- OkLab gradient interpolation in OkLab, OkLCH, Lab, LCH, HSL, HWB.
- CanvasKit filter parity (
ColorFilter,ImageFilter). - Font registration from buffers without writing to disk.
- Variable font axis control (
wght,wdth,opsz,slnt, custom axes). - Linear-light premultiplied colors plumbed through paint, gradient, filter, text.
ParagraphBuilder/Paragraphrich text with mixed styles, per-run shadows, hit-testing, line metrics.
Rust
[dependencies]
skia-canvas = { version = "0.2", default-features = false, features = ["vulkan", "freetype"] }The stable Rust API is the crate root, re-exported through skia_canvas::prelude. Public signatures never expose skia_safe or neon types -- a compile-time pin in tests/native_studio_renderer_adapter.rs enforces this; the Node/Neon binding lives under the internal node module.
use skia_canvas::prelude::*;
let backend = Backend::new();
let mut surface = backend.create_surface(
1920,
1080,
SurfaceOptions {
color_space: LinearColorSpace::DisplayP3,
..SurfaceOptions::default()
},
)?;
surface.with_canvas(|canvas| {
canvas.clear(RgbaLinear::new_premultiplied(0.0, 0.0, 0.0, 0.0));
canvas.draw_rect(
Rect::from_xywh(100.0, 100.0, 200.0, 100.0),
&Paint::fill(RgbaLinear::opaque(1.0, 0.0, 0.0)),
);
});
let frame = surface.read_pixels()?; // tight RGBA8, sRGB-gamma, unpremultipliedSee docs/api/native-rust.md for the reference and examples/ for runnable code.
Cargo features
| Feature | Notes |
|---|---|
| vulkan | Vulkan backend (Linux / Windows). |
| metal | Metal backend (macOS). |
| window | winit-backed event loop. |
| freetype | Bundle FreeType + WOFF2 (recommended on minimal containers). |
| node-addon | Register the #[neon::main] Node addon entry point. Pure-Rust consumers leave this off. |
Default feature set is empty; opt in to the backend you need.
Skia version
| skia-canvas | skia-safe | Skia milestone |
|---|---|---|
| 0.2.x | 0.97.x | M148 |
The Skia revision is pinned by skia-safe; bumping skia-safe is a skia-canvas minor-version event.
Node.js
The same source tree also produces the phyron-skia-canvas npm package.
npm install phyron-skia-canvasimport { Canvas } from "phyron-skia-canvas";
let canvas = new Canvas(1920, 1080, {
colorType: "rgbaf16",
colorSpace: "rec2020-pq", // HDR10
});See docs/node.md for installation, platform support (Linux / Docker / AWS Lambda / Next.js), the JavaScript API, and benchmarks.
Acknowledgements
Built on top of the rust-skia project (skia-safe + skia-bindings). Forked from samizdatco/skia-canvas; many thanks to its contributors.
License
MIT. See LICENSE.
© 2020–2026 Samizdat Drafting Co., Phyron AB and contributors.
