layer_canvas 0.1.0
layer_canvas: ^0.1.0 copied to clipboard
High-performance 2D compositing engine for Dart and Flutter, using Blend2D via FFI to render typed Layers to PNG/BMP/QOI at native speed.
0.1.0 #
Layer.clipToBounds— clips a layer's own painted content to its ownsizebox, in its own local (post-transform) space, so the clip moves and rotates with the layer exactly like its paint geometry. Requires an explicitsize; no effect onGroup, which is expanded into its concrete descendants before reaching the native renderer, leaving no single composited surface to clip.TextLayerword-wrap — text always breaks on an explicit\n, and additionally word-wraps to fitsize's width when one is given, greedily and only at spaces (a single word wider than the box overflows on its own line rather than being split mid-word). The wrapped block is vertically centered withinsize's height, same as a single line always was.
0.1.0-beta.6 #
- JSON serialization — every model type (
Scene, allLayersubtypes,LayerPaint,Gradient,LayerPath,LayerImageSource, etc.) gains atoJson()and a matchingfromJson/Gradient.fromJson-style constructor.LayerRegistry.registerLayer/registerImageSourcelet a customLayer/LayerImageSourcesubclass round-trip throughScene.toJson/Scene.fromJsontoo, without changing this package. LayerTransformnow has value equality (operator ==/hashCode), matchingPoint2D/Size2D/Color32.TextWeight.fromValue(int)— a new factory for constructing a weight outside the 7 named constants (previously impossible, sinceTextWeight's constructor was private).
0.1.0-beta.5 #
- Stroke cap/join/miter limit —
LayerPaint.strokeCap(butt/round/square),strokeJoin(miter/round/bevel), andmiterLimitcontrol how a stroke's open ends and corners are drawn, on bothRectangleLayerandPathLayer. - Dash patterns —
LayerPaint.dashArray/dashOffsetonPathLayerstrokes (an odd-length array repeats, matching SVG/CSS). Resolved into plain path geometry on the Dart side rather than delegated to Blend2D, whose own dash support is a long-standing no-op (blend2d/blend2d#48); not currently supported onRectangleLayer, which has no path geometry of its own to dash. OutputFormat—Renderer.render/renderToFiletake aformatparameter (png, the default,bmp, orqoi) to encode as something other than PNG. No JPEG: this build's JPEG codec only decodes, it can't encode.
0.1.0-beta.4 #
hitTestScene— given aSceneand a point (in its own logical pixel space), returns the topmost visibleLayerwhose bounding box contains it, ornull. Built on the sameGroup/transform compositionflattenScenealready resolves internally for rendering, so a rotated, scaled, or nested-in-a-group layer's hit box moves exactly the way its paint geometry does. A bounding-box test againstLayer.size(not the exact painted shape), and a layer with no explicitsize(intrinsic sizing) never matches — see the doc comment for the precise contract. This is what lets a consumer (e.g.layer_canvas_flutter) offer tap handling without reimplementing this package's own transform math.
0.1.0-beta.3 #
New layer capabilities and SVG import.
- Gradients —
LinearGradient,RadialGradient,ConicGradient; anyRectangleLayerorPathLayercan be painted with a gradient instead of a solid color viaLayerPaint.gradient. PathLayer— arbitrary vector geometry: lines, quadratic/cubic Bézier curves, arcs (SVG-compatibleArcTo), and closed subpaths, withFillRule.nonZero/evenOdd.LayerPath.polygon,.polyline,.circle, and.ellipsecover the common cases;PathLayer.filledis a solid-fill shortcut.- SVG import —
SvgDocument.parsereads shapes, gradients, and paths from an SVG string;.toGroup()turns the result into layers that compose into aScenelike any other layer. - Multi-weight fonts —
FontRegistry.register/unregisternow take aweight, so a single family can have several weights registered at once;TextLayerrenders with whichever registered weight is numerically closest to its ownfontWeight. RectangleLayer.filled— a plain width/height/color constructor for the common solid-fill case, alongside the existingPathLayer.filled.
0.1.0-beta.2 #
Documentation-only release: updated README with Flutter integration
details and an architecture diagram, and excluded unnecessary
Blend2D submodule files from the published package via .pubignore.
0.1.0-beta.1 #
First functional beta. RectangleLayer, TextLayer, ImageLayer, and
Group all render natively; Scene.background composites a full-canvas
image underneath everything else.
RectangleLayer— fill/stroke/fill-and-stroke, corner radius, full 2D transform (position, rotation, scale, anchor).TextLayer— native text rendering with an embedded Roboto (regular and bold); custom fonts can be registered globally viaFontRegistryand referenced byfontFamily. The embedded font (~1.4 MB) can be dropped from the compiled library withhooks.user_defines.layer_canvas.embed_default_font: false.ImageLayer— decodes PNG/JPEG/BMP/QOI automatically;fitsupportsfill,contain,cover, andnone.Group— nests arbitrarily; flattened into concrete layers by the renderer before crossing the FFI boundary, so the native engine has no concept of groups.Scene.background— an optionalLayerImageSourcepainted before any layer, scaled to cover the whole canvas.- Fixed an Android
dlopendeadlock caused by athread_localsegment in a vendored dependency, and hardened the x86/x86_64 SIMD build to match the Android NDK's baseline compiler defines.
0.0.1 #
Initial package scaffold (from the package:ffi native-assets template)
with RectangleLayer rendering end to end through Blend2D.