Preparing search index...

    Class VectorCompositeBuilder

    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(); subsequent addPath calls and another build() produce an independent composite.

    Lens Scripting Version 370

    var builder = VectorCompositeBuilder.create(256, 256);
    var pathBuilder = VectorPathBuilder.create();
    pathBuilder.moveTo(new vec2(0, 0));
    pathBuilder.lineTo(new vec2(100, 0));
    pathBuilder.lineTo(new vec2(50, 100));
    var path = pathBuilder.build();
    builder.addPath(path, VectorPaint.solid(new vec4(1, 0, 0, 1)), VectorComposite.FillRule.NonZero);
    var composite = builder.build();
    composite.ready().then(function () {
    var renderer = new VectorRenderer();
    var target = scene.createRenderTargetTexture();
    target.control.outputResolution = RenderTargetProvider.OutputResolution.Custom;
    target.control.resolution = new vec2(256, 256);
    // render() is cheap to repeat — call it again (e.g. from an UpdateEvent)
    // whenever the target size or placement changes.
    renderer.render(target, composite, null);
    });

    Hierarchy (View Summary)

    Index

    Methods

    • 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.

      Parameters

      • path: VectorPath

        The path geometry to fill.

      • paint: VectorPaint

        The paint (solid color or gradient) to fill it with.

      • fillRule: FillRule

        The fill rule for this path.

      Returns void

      Lens Scripting Version 370

      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.

      Parameters

      Returns void

      Lens Scripting Version 370

      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).

      Parameters

      • text: VectorText

        The text run content and style.

      • paint: VectorPaint

        The paint to draw the run with (a solid color only).

      • position: vec2

        The baseline anchor position, in the composite's coordinate space.

      • rotation: number

        Rotation about the baseline position, in degrees, clockwise.

      Returns void

      Lens Scripting Version 374

      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.

      Returns VectorComposite

      Lens Scripting Version 370

    • Creates 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.

      Parameters

      • width: number

        Canvas width in pixels (must be > 0).

      • height: number

        Canvas height in pixels (must be > 0).

      Returns VectorCompositeBuilder

      Lens Scripting Version 370

    • Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

      Returns string

      Lens Scripting Version 370

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean