skia
    Preparing search index...

    Interface PathBuilder

    CanvasKit is built with Emscripten and Embind. Embind adds the following methods to all objects that are exposed with it. This _type field is necessary for the TypeScript compiler to differentiate between opaque types such as Shader and ColorFilter. It doesn't exist at runtime.

    interface PathBuilder {
        _type: "SkPathBuilder";
        addArc(
            oval: InputRect,
            startAngle: number,
            sweepAngle: number,
        ): PathBuilder;
        addCircle(x: number, y: number, r: number, isCCW?: boolean): PathBuilder;
        addOval(oval: InputRect, isCCW?: boolean, startIndex?: number): PathBuilder;
        addPath(...args: any[]): PathBuilder | null;
        addPolygon(points: InputFlattenedPointArray, close: boolean): PathBuilder;
        addRect(rect: InputRect, isCCW?: boolean): PathBuilder;
        addRRect(rrect: InputRRect, isCCW?: boolean): PathBuilder;
        addVerbsPointsWeights(
            verbs: VerbList,
            points: InputFlattenedPointArray,
            weights?: WeightList,
        ): PathBuilder;
        arc(
            x: number,
            y: number,
            radius: number,
            startAngle: number,
            endAngle: number,
            isCCW?: boolean,
        ): PathBuilder;
        arcToOval(
            oval: InputRect,
            startAngle: number,
            endAngle: number,
            forceMoveTo: boolean,
        ): PathBuilder;
        arcToRotated(
            rx: number,
            ry: number,
            xAxisRotate: number,
            useSmallArc: boolean,
            isCCW: boolean,
            x: number,
            y: number,
        ): PathBuilder;
        arcToTangent(
            x1: number,
            y1: number,
            x2: number,
            y2: number,
            radius: number,
        ): PathBuilder;
        close(): Path;
        conicTo(
            x1: number,
            y1: number,
            x2: number,
            y2: number,
            w: number,
        ): PathBuilder;
        contains(x: number, y: number): boolean;
        countPoints(): number;
        cubicTo(
            cpx1: number,
            cpy1: number,
            cpx2: number,
            cpy2: number,
            x: number,
            y: number,
        ): PathBuilder;
        delete(): void;
        deleteLater(): void;
        detach(): Path;
        detachAndDelete(): Path;
        getBounds(outputArray?: Rect): Rect;
        isAliasOf(other: any): boolean;
        isDeleted(): boolean;
        isEmpty(): boolean;
        lineTo(x: number, y: number): PathBuilder;
        moveTo(x: number, y: number): PathBuilder;
        offset(dx: number, dy: number): PathBuilder;
        quadTo(x1: number, y1: number, x2: number, y2: number): PathBuilder;
        rArcTo(
            rx: number,
            ry: number,
            xAxisRotate: number,
            useSmallArc: boolean,
            isCCW: boolean,
            dx: number,
            dy: number,
        ): PathBuilder;
        rConicTo(
            dx1: number,
            dy1: number,
            dx2: number,
            dy2: number,
            w: number,
        ): PathBuilder;
        rCubicTo(
            cpx1: number,
            cpy1: number,
            cpx2: number,
            cpy2: number,
            x: number,
            y: number,
        ): PathBuilder;
        rLineTo(x: number, y: number): PathBuilder;
        rMoveTo(x: number, y: number): PathBuilder;
        rQuadTo(x1: number, y1: number, x2: number, y2: number): PathBuilder;
        setFillType(fill: EmbindEnumEntity): void;
        snapshot(): Path;
        transform(...args: any[]): PathBuilder;
    }

    Hierarchy (View Summary)

    Index

    Properties

    _type: "SkPathBuilder"

    Methods

    • Appends arc to Path, as the start of new contour. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise. Returns the modified path for easier chaining.

      Parameters

      • oval: InputRect
      • startAngle: number
      • sweepAngle: number

      Returns PathBuilder

    • Adds circle centered at (x, y) of size radius to the path. Has no effect if radius is zero or negative.

      Parameters

      • x: number

        center of circle

      • y: number

        center of circle

      • r: number
      • OptionalisCCW: boolean

        if the path should be drawn counter-clockwise or not

      Returns PathBuilder

      reference to SkPath

    • Adds oval to Path, appending kMove_Verb, four kConic_Verb, and kClose_Verb. Oval is upright ellipse bounded by Rect oval with radii equal to half oval width and half oval height. Oval begins at start and continues clockwise by default. Returns the modified path for easier chaining.

      Parameters

      • oval: InputRect
      • OptionalisCCW: boolean

        if the path should be drawn counter-clockwise or not

      • OptionalstartIndex: number

        index of initial point of ellipse

      Returns PathBuilder

    • Takes 1, 2, 7, or 10 required args, where the first arg is always the path. The last arg is an optional boolean and chooses between add or extend mode. The options for the remaining args are:

      • an array of 6 or 9 parameters (perspective is optional)
      • the 9 parameters of a full matrix or the 6 non-perspective params of a matrix. Returns the modified path for easier chaining (or null if params were incorrect).

      Parameters

      • ...args: any[]

      Returns PathBuilder | null

    • Adds contour created from array of n points, adding (count - 1) line segments. Contour added starts at pts[0], then adds a line for every additional point in pts array. If close is true, appends kClose_Verb to Path, connecting pts[count - 1] and pts[0]. Returns the modified path for easier chaining.

      Parameters

      Returns PathBuilder

    • Adds Rect to Path, appending kMove_Verb, three kLine_Verb, and kClose_Verb, starting with top-left corner of Rect; followed by top-right, bottom-right, and bottom-left if isCCW is false; or followed by bottom-left, bottom-right, and top-right if isCCW is true. Returns the modified path for easier chaining.

      Parameters

      Returns PathBuilder

    • Adds the given verbs and associated points/weights to the path. The process reads the first verb from verbs and then the appropriate number of points from the FlattenedPointArray (e.g. 2 points for moveTo, 4 points for quadTo, etc). If the verb is a conic, a weight will be read from the WeightList. The verb list should start with a moveTo since the previous location will be lost. Returns the modified path for easier chaining

      Parameters

      • verbs: VerbList

        the verbs that create this path, in the order of being drawn.

      • points: InputFlattenedPointArray

        represents n points with 2n floats.

      • Optionalweights: WeightList

        used if any of the verbs are conics, can be omitted otherwise.

      Returns PathBuilder

    • Adds an arc to this path, emulating the Canvas2D behavior. Returns the modified path for easier chaining.

      Parameters

      • x: number
      • y: number
      • radius: number
      • startAngle: number
      • endAngle: number
      • OptionalisCCW: boolean

      Returns PathBuilder

    • Appends arc to Path. Arc added is part of ellipse bounded by oval, from startAngle through sweepAngle. Both startAngle and sweepAngle are measured in degrees, where zero degrees is aligned with the positive x-axis, and positive sweeps extends arc clockwise. Returns the modified path for easier chaining.

      Parameters

      • oval: InputRect
      • startAngle: number
      • endAngle: number
      • forceMoveTo: boolean

      Returns PathBuilder

    • Appends arc to Path. Arc is implemented by one or more conics weighted to describe part of oval with radii (rx, ry) rotated by xAxisRotate degrees. Arc curves from last Path Point to (x, y), choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger. See SkPath.h for more details. Returns the modified path for easier chaining.

      Parameters

      • rx: number
      • ry: number
      • xAxisRotate: number
      • useSmallArc: boolean
      • isCCW: boolean
      • x: number
      • y: number

      Returns PathBuilder

    • Appends arc to Path, after appending line if needed. Arc is implemented by conic weighted to describe part of circle. Arc is contained by tangent from last Path point to (x1, y1), and tangent from (x1, y1) to (x2, y2). Arc is part of circle sized to radius, positioned so it touches both tangent lines. Returns the modified path for easier chaining.

      Parameters

      • x1: number
      • y1: number
      • x2: number
      • y2: number
      • radius: number

      Returns PathBuilder

    • Appends CLOSE_VERB to Path. A closed contour connects the first and last point with a line, forming a continuous loop. Returns the modified path for easier chaining.

      Returns Path

    • Adds conic from last point towards (x1, y1), to (x2, y2), weighted by w. If Path is empty, or path is closed, the last point is set to (0, 0) before adding conic. Returns the modified path for easier chaining.

      Parameters

      • x1: number
      • y1: number
      • x2: number
      • y2: number
      • w: number

      Returns PathBuilder

    • Returns true if the point (x, y) is contained by current Path, taking into account FillType.

      Parameters

      • x: number
      • y: number

      Returns boolean

    • Returns the number of points in this path. Initially zero.

      Returns number

    • Adds cubic from last point towards (x1, y1), then towards (x2, y2), ending at (x3, y3). If Path is empty, or path is closed, the last point is set to (0, 0) before adding cubic.

      Parameters

      • cpx1: number
      • cpy1: number
      • cpx2: number
      • cpy2: number
      • x: number
      • y: number

      Returns PathBuilder

    • Returns an immutable Path with all the drawing so far and resets the internal buffers to be empty.

      Returns Path

    • Returns an immutable Path with all the drawing so far and calls delete() on this JS object, freeing the memory associated with it.

      Returns Path

    • Returns minimum and maximum axes values of Point array. Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may be larger or smaller than area affected when Path is drawn.

      Parameters

      • OptionaloutputArray: Rect

        if provided, the bounding box will be copied into this array instead of allocating a new one.

      Returns Rect

    • Returns true if there are no verbs in the path.

      Returns boolean

    • Adds line from last point to (x, y). If Path is empty, or last path is closed, last point is set to (0, 0) before adding line. Returns the modified path for easier chaining.

      Parameters

      • x: number
      • y: number

      Returns PathBuilder

    • Adds beginning of contour at the given point. Returns the modified path for easier chaining.

      Parameters

      • x: number
      • y: number

      Returns PathBuilder

    • Translates all the points in the path by dx, dy. Returns the modified path for easier chaining.

      Parameters

      • dx: number
      • dy: number

      Returns PathBuilder

    • Adds quad from last point towards (x1, y1), to (x2, y2). If Path is empty, or path is closed, last point is set to (0, 0) before adding quad. Returns the modified path for easier chaining.

      Parameters

      • x1: number
      • y1: number
      • x2: number
      • y2: number

      Returns PathBuilder

    • Relative version of arcToRotated.

      Parameters

      • rx: number
      • ry: number
      • xAxisRotate: number
      • useSmallArc: boolean
      • isCCW: boolean
      • dx: number
      • dy: number

      Returns PathBuilder

    • Relative version of conicTo.

      Parameters

      • dx1: number
      • dy1: number
      • dx2: number
      • dy2: number
      • w: number

      Returns PathBuilder

    • Relative version of cubicTo.

      Parameters

      • cpx1: number
      • cpy1: number
      • cpx2: number
      • cpy2: number
      • x: number
      • y: number

      Returns PathBuilder

    • Returns an immutable Path with all the drawing so far. Keeps the current points, verbs, and weights for continued growth.

      Returns Path