vector-clipper
Garnet vector Clipper adapter
require "garnet-vector-clipper" adds optional native Boolean geometry, offsets and triangulation. The core vector shard retains its standalone Crystal tessellator and has no Clipper dependency.
require "garnet-vector-clipper"
alias V = Garnet::Vector
ring = V::Clipper.combine(V::Path.rect(0, 0, 100, 100),
V::Path.circle(50, 50, 30), :difference)
expanded = V::Clipper.offset(ring, 2, join: :round)
primitive = V::Clipper::Shape.new(expanded, Garnet::Color::WHITE)
recorder.draw(primitive)
combine normalizes each input using its own fill rule before applying intersection, union, difference or xor. offset expands/contracts filled geometry. Both return neutral polygonal Path resources: curves are flattened at the requested tolerance and coordinates quantized at the requested decimal precision. They do not preserve analytic curve commands. The default tolerance is 0.01, precision 6, input budget 65,536 flattened vertices; normal path subdivision limits also apply.
mesh resolves the fill rule then uses Clipper2 triangulation, returning a generic graphics mesh or nil for empty geometry. Clipper::Shape uses it through the existing primitive contract, so colors, gradients, image patterns, scene containers, masks and effects work through the same renderer APIs. No rendering is performed by Clipper2.
Install dependencies with shards install; see clipper build requirements. Run scripts/check-composition unit and native backend modes from the workspace for geometry and shared pixel fixtures. macOS GL/GLES, Metal and Vulkan have been exercised; this does not verify other operating systems.
vector-clipper
- 0
- 0
- 0
- 1
- 2
- 1 day ago
- November 30, 2026
MIT License
Wed, 02 Dec 2026 02:09:29 GMT