Appends a filled path to the composite. path is an immutable
VectorPath; paint is a VectorPaint — a solid color
(VectorPaint.solid) or a gradient (VectorPaint.gradient);
fillRule is one of VectorComposite.FillRule.NonZero (the SVG default
winding rule) or VectorComposite.FillRule.EvenOdd. Both path and paint
are referenced as-is — a single VectorPaint may be passed to multiple
addPath calls to fill several paths with one paint.
The path geometry to fill.
The paint (solid color or gradient) to fill it with.
The fill rule for this path.
var builder = VectorCompositeBuilder.create(512, 512);
// Build a path.
var pathBuilder = VectorPathBuilder.create();
pathBuilder.moveTo(new vec2(0, 0));
pathBuilder.lineTo(new vec2(512, 0));
pathBuilder.lineTo(new vec2(256, 512));
var path = pathBuilder.build();
// Solid fill.
builder.addPath(path, VectorPaint.solid(new vec4(0.92, 0.26, 0.21, 1.0)),
VectorComposite.FillRule.NonZero);
// Gradient fill — build a reusable gradient, then wrap it in a paint.
var gb = VectorGradientBuilder.linear(new vec2(0, 0), new vec2(512, 0));
gb.addColorStop(0.0, new vec4(0.92, 0.26, 0.21, 1.0));
gb.addColorStop(1.0, new vec4(0.13, 0.59, 0.95, 1.0));
builder.addPath(path, VectorPaint.gradient(gb.build()),
VectorComposite.FillRule.NonZero);
var composite = builder.build();
Appends a stroked path to the composite. path is an immutable
VectorPath; paint is a VectorPaint — a solid color
(VectorPaint.solid) or a gradient (VectorPaint.gradient);
stroke is an immutable VectorStroke that carries the stroke style
(width, line cap, line join, miter limit, and an optional dash pattern).
Both path, paint, and stroke are referenced as-is — a single
VectorStroke may be passed to multiple addStroke calls to stroke
several paths with one style.
To paint a path with both a fill and a stroke, call VectorCompositeBuilder#addPath
followed by addStroke on the same path: the fill (added first) draws under the stroke.
The path geometry to stroke.
The paint (solid color or gradient) to stroke with.
The stroke style.
var builder = VectorCompositeBuilder.create(512, 512);
// Build a path.
var pathBuilder = VectorPathBuilder.create();
pathBuilder.moveTo(new vec2(0, 0));
pathBuilder.lineTo(new vec2(512, 0));
pathBuilder.lineTo(new vec2(256, 512));
var path = pathBuilder.build();
// Solid stroke.
var sb = VectorStrokeBuilder.create(6);
sb.setCap(VectorComposite.LineCap.Round);
var stroke = sb.build();
builder.addStroke(path, VectorPaint.solid(new vec4(0.92, 0.26, 0.21, 1.0)), stroke);
Appends a text run to the composite. text is an immutable VectorText
produced by VectorTextBuilder#build; paint is a VectorPaint —
only a solid color is supported for text in this version (a gradient paint
throws); position is the run's baseline anchor position, in the composite's
coordinate space (where it falls relative to the run's glyphs depends on the
text's anchor); rotation rotates the run
about that position, in degrees, clockwise (0 = axis-aligned).
The text run content and style.
The paint to draw the run with (a solid color only).
The baseline anchor position, in the composite's coordinate space.
Rotation about the baseline position, in degrees, clockwise.
var builder = VectorCompositeBuilder.create(512, 128);
var tb = VectorTextBuilder.create("Hello", 48);
tb.setHorizontalAlignment(HorizontalAlignment.Center);
var text = tb.build();
builder.addText(text, VectorPaint.solid(new vec4(1, 1, 1, 1)), new vec2(256, 64), 0);
var composite = builder.build();
Snapshots the accumulated fills into a new, unregistered
VectorComposite and returns it. The composite is not yet built
(not ready); call VectorComposite#ready to tessellate it
asynchronously, or — in a C++ unit test — call buildRetained() directly.
The builder remains usable after build(); further addPath calls and
another build() produce an independent composite.
StaticcreateCreates a new, empty builder for a composite of the given pixel dimensions.
width and height define the coordinate space of the composite and its
intrinsic size once built.
Canvas width in pixels (must be > 0).
Canvas height in pixels (must be > 0).
StaticgetReturns the name of this object's type.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Assigns the font source used to resolve VectorCompositeBuilder#addText runs in the composite produced by VectorCompositeBuilder#build — a Font, FontFamily, or FontCollection asset, exactly like VectorComposite#fontSource.
The font source (a Font, FontFamily, or FontCollection asset, or null).
A mutable builder for a VectorComposite assembled from programmatic fills — each a path painted with a VectorPaint (a solid color or a gradient). Create one with VectorCompositeBuilder.create, add filled paths with VectorCompositeBuilder#addPath, then call VectorCompositeBuilder#build to produce the composite. The builder remains usable after
build(); subsequentaddPathcalls and anotherbuild()produce an independent composite.Since
Lens Scripting Version 370
Snap OS
Example