Interface Path

A D3 path serializer implementing CanvasPathMethods

interface Path {
    arc(x, y, radius, startAngle, endAngle, anticlockwise?): void;
    arcTo(x1, y1, x2, y2, radius): void;
    bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y): void;
    closePath(): void;
    lineTo(x, y): void;
    moveTo(x, y): void;
    quadraticCurveTo(cpx, cpy, x, y): void;
    rect(x, y, w, h): void;
    toString(): string;
}

Methods

  • Draws a circular arc segment with the specified center ⟨x, y⟩, radius, startAngle and endAngle. If anticlockwise is true, the arc is drawn in the anticlockwise direction; otherwise, it is drawn in the clockwise direction. If the current point is not equal to the starting point of the arc, a straight line is drawn from the current point to the start of the arc. Equivalent to context.arc and uses SVG’s elliptical arc curve commands.

    Parameters

    • x: number

      x-Coordinate of the center point of the arc segment

    • y: number

      y-Coordinate of the center point of the arc segment

    • radius: number
    • startAngle: number

      Start angle of arc segment

    • endAngle: number

      End angle of arc segment

    • Optional anticlockwise: boolean

      Flag indicating directionality (true = anti-clockwise, false = clockwise)

    Returns void

  • Draws a circular arc segment with the specified radius that starts tangent to the line between the current point and the specified point ⟨x1, y1⟩ and ends tangent to the line between the specified points ⟨x1, y1⟩ and ⟨x2, y2⟩. If the first tangent point is not equal to the current point, a straight line is drawn between the current point and the first tangent point. Equivalent to context.arcTo and uses SVG’s elliptical arc curve commands.

    Parameters

    • x1: number

      x-Coordinate of the first tangent point

    • y1: number

      y-Coordinate of the first tangent point

    • x2: number

      x-Coordinate of the second tangent point

    • y2: number

      y-Coordinate of the second tangent point

    • radius: number

    Returns void

  • Draws a cubic Bézier segment from the current point to the specified point ⟨x, y⟩, with the specified control points ⟨cpx1, cpy1⟩ and ⟨cpx2, cpy2⟩. Equivalent to context.bezierCurveTo and SVG’s cubic Bézier curve commands.

    Parameters

    • cpx1: number

      x-Coordinate of the first control point for the Bézier curve

    • cpy1: number

      y-Coordinate of the first control point for the Bézier curve

    • cpx2: number

      x-Coordinate of the second control point for the Bézier curve

    • cpy2: number

      y-Coordinate of the second control point for the Bézier curve

    • x: number

      x-Coordinate of point to draw the curve to

    • y: number

      y-Coordinate of point to draw the curve to

    Returns void

  • Ends the current subpath and causes an automatic straight line to be drawn from the current point to the initial point of the current subpath. Equivalent to context.closePath and SVG’s “closepath” command.

    Returns void

  • Draws a straight line from the current point to the specified point ⟨x, y⟩. Equivalent to context.lineTo and SVG’s “lineto” command.

    Parameters

    • x: number

      x-Coordinate of point to draw the line to

    • y: number

      y-Coordinate of point to draw the line to

    Returns void

  • Move to the specified point ⟨x, y⟩. Equivalent to context.moveTo and SVG’s “moveto” command.

    Parameters

    • x: number

      x-Coordinate of point to move to

    • y: number

      y-Coordinate of point to move to

    Returns void

  • Draws a quadratic Bézier segment from the current point to the specified point ⟨x, y⟩, with the specified control point ⟨cpx, cpy⟩. Equivalent to context.quadraticCurveTo and SVG’s quadratic Bézier curve commands.

    Parameters

    • cpx: number

      x-Coordinate of the control point for the quadratic Bézier curve

    • cpy: number

      y-Coordinate of the control point for the quadratic Bézier curve

    • x: number

      x-Coordinate of point to draw the curve to

    • y: number

      y-Coordinate of point to draw the curve to

    Returns void

  • Creates a new subpath containing just the four points ⟨x, y⟩, ⟨x + w, y⟩, ⟨x + w, y + h⟩, ⟨x, y + h⟩, with those four points connected by straight lines, and then marks the subpath as closed. Equivalent to context.rect and uses SVG’s “lineto” commands.

    Parameters

    • x: number

      x-Coordinate of starting point for drawing the rectangle

    • y: number

      y-Coordinate of starting point for drawing the rectangle

    • w: number

      Width of rectangle

    • h: number

      Height of rectangle

    Returns void

  • Returns the string representation of this path according to SVG’s path data specification.

    Returns string