PathBuilder


PathBuilder provides a fluent API to creates a list of PathNode, used to describe a path.

Summary

Public constructors

Cmn

Public functions

PathBuilder
arcTo(
    horizontalEllipseRadius: Float,
    verticalEllipseRadius: Float,
    theta: Float,
    isMoreThanHalf: Boolean,
    isPositiveArc: Boolean,
    x1: Float,
    y1: Float
)

Add an elliptical arc from the last point to the position (x1, y1) by adding PathNode.ArcTo to nodes.

Cmn
PathBuilder
arcToRelative(
    a: Float,
    b: Float,
    theta: Float,
    isMoreThanHalf: Boolean,
    isPositiveArc: Boolean,
    dx1: Float,
    dy1: Float
)

Add an elliptical arc by adding PathNode.RelativeArcTo to nodes.

Cmn
PathBuilder

Closes the current contour by adding a PathNode.Close to nodes.

Cmn
PathBuilder
curveTo(x1: Float, y1: Float, x2: Float, y2: Float, x3: Float, y3: Float)

Add a cubic Bézier from the last point to the position (x3, y3), approaching the control points (x1, y1) and (x2, y2), by adding a PathNode.CurveTo to nodes.

Cmn
PathBuilder
curveToRelative(
    dx1: Float,
    dy1: Float,
    dx2: Float,
    dy2: Float,
    dx3: Float,
    dy3: Float
)

Add a cubic Bézier by adding a PathNode.CurveTo to nodes.

Cmn
PathBuilder

Add a line from the last point to the position (x, oy), where oy is the y coordinate of the last point, by adding a PathNode.HorizontalTo to nodes.

Cmn
PathBuilder

Add a line from the last point to the position (dx + ox, oy), where ox and oy are the x and y coordinates of the last point, by adding a PathNode.RelativeHorizontalTo to nodes.

Cmn
PathBuilder
lineTo(x: Float, y: Float)

Add a line from the last point to the position (x, y) by adding a PathNode.LineTo to nodes.

Cmn
PathBuilder

Add a line from the last point to the offset (dx, dy) relative to the last point by adding a PathNode.RelativeLineTo to nodes.

Cmn
PathBuilder
moveTo(x: Float, y: Float)

Start a new contour at position (x, y) by adding a PathNode.MoveTo to nodes.

Cmn
PathBuilder

Start a new contour at the offset (dx, dy) relative to the last path position by adding a PathNode.RelativeMoveTo to nodes.

Cmn
PathBuilder
quadTo(x1: Float, y1: Float, x2: Float, y2: Float)

Add a quadratic Bézier from the last point to the position (x2, y2), approaching the control point (x1, y1), by adding a PathNode.QuadTo to nodes.

Cmn
PathBuilder
quadToRelative(dx1: Float, dy1: Float, dx2: Float, dy2: Float)

Add a quadratic Bézier by adding a PathNode.RelativeQuadTo to nodes.

Cmn
PathBuilder
reflectiveCurveTo(x1: Float, y1: Float, x2: Float, y2: Float)

Add a cubic Bézier from the last point to the position (x2, y2).

Cmn
PathBuilder
reflectiveCurveToRelative(dx1: Float, dy1: Float, dx2: Float, dy2: Float)

Add a cubic Bézier by adding a PathNode.RelativeReflectiveCurveTo to nodes.

Cmn
PathBuilder

Add a quadratic Bézier from the last point to the position (x1, y1).

Cmn
PathBuilder

Add a quadratic Bézier by adding a PathNode.RelativeReflectiveQuadTo to nodes.

Cmn
PathBuilder

Add a line from the last point to the position (ox, y), where ox is the x coordinate of the last point, by adding a PathNode.VerticalTo to nodes.

Cmn
PathBuilder

Add a line from the last point to the position (ox, dy + oy), where ox and oy are the x and y coordinates of the last point, by adding a PathNode.RelativeVerticalTo to nodes.

Cmn

Public properties

List<PathNode>

Returns the list of PathNode currently held in this builder.

Cmn

Public constructors

PathBuilder

PathBuilder()

Public functions

arcTo

fun arcTo(
    horizontalEllipseRadius: Float,
    verticalEllipseRadius: Float,
    theta: Float,
    isMoreThanHalf: Boolean,
    isPositiveArc: Boolean,
    x1: Float,
    y1: Float
): PathBuilder

Add an elliptical arc from the last point to the position (x1, y1) by adding PathNode.ArcTo to nodes. If no contour has been created by calling moveTo first, the origin of the arc is set to (0, 0).

The ellipse is defined by 3 parameters:

In most situations, there are four arc candidates that can be drawn from the origin to (x1, y1). Which of the arcs is used is influenced by isMoreThanHalf and isPositiveArc.

When isMoreThanHalf is set to true, the added arc will be chosen amongst the two candidates that represent an arc sweep greater than or equal to 180 degrees.

When isPositiveArc is set to true, the added arc will be chosen amongst the two candidates with a positive-angle direction (counter-clockwise)

Parameters
horizontalEllipseRadius: Float

The horizontal radius of the ellipse

verticalEllipseRadius: Float

The vertical radius of the ellipse

theta: Float

The rotation of the ellipse around the X-axis, in degrees

isMoreThanHalf: Boolean

Defines whether to use an arc candidate with a sweep greater than or equal to 180 degrees

isPositiveArc: Boolean

Defines whether to use an arc candidate that's counter-clockwise or not

x1: Float

The x coordinate of the end point of the arc

y1: Float

The y coordinate of the end point of the arc

arcToRelative

fun arcToRelative(
    a: Float,
    b: Float,
    theta: Float,
    isMoreThanHalf: Boolean,
    isPositiveArc: Boolean,
    dx1: Float,
    dy1: Float
): PathBuilder

Add an elliptical arc by adding PathNode.RelativeArcTo to nodes. If no contour has been created by calling moveTo first, the origin of the arc is set to (0, 0). The arc Bézier end point is defined by an offset relative to the last point.

The ellipse is defined by 3 parameters:

  • a and b to define the size of the ellipse

  • theta to define the orientation (as an X-axis rotation) of the ellipse

In most situations, there are four arc candidates that can be drawn from the origin to the end point. Which of the arcs is used is influenced by isMoreThanHalf and isPositiveArc.

When isMoreThanHalf is set to true, the added arc will be chosen amongst the two candidates that represent an arc sweep greater than or equal to 180 degrees.

When isPositiveArc is set to true, the added arc will be chosen amongst the two candidates with a positive-angle direction (counter-clockwise)

Parameters
a: Float

The horizontal radius of the ellipse

b: Float

The vertical radius of the ellipse

theta: Float

The rotation of the ellipse around the X-axis, in degrees

isMoreThanHalf: Boolean

Defines whether to use an arc candidate with a sweep greater than or equal to 180 degrees

isPositiveArc: Boolean

Defines whether to use an arc candidate that's counter-clockwise or not

dx1: Float

The x offset of the end point of the arc, relative to the last path position

dy1: Float

The y offset of the end point of the arc, relative to the last path position

close

fun close(): PathBuilder

Closes the current contour by adding a PathNode.Close to nodes.

curveTo

fun curveTo(x1: Float, y1: Float, x2: Float, y2: Float, x3: Float, y3: Float): PathBuilder

Add a cubic Bézier from the last point to the position (x3, y3), approaching the control points (x1, y1) and (x2, y2), by adding a PathNode.CurveTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0).

Parameters
x1: Float

The x coordinate of the first control point of the cubic curve

y1: Float

The y coordinate of the first control point of the cubic curve

x2: Float

The x coordinate of the second control point of the cubic curve

y2: Float

The y coordinate of the second control point of the cubic curve

x3: Float

The x coordinate of the end point of the cubic curve

y3: Float

The y coordinate of the end point of the cubic curve

curveToRelative

fun curveToRelative(
    dx1: Float,
    dy1: Float,
    dx2: Float,
    dy2: Float,
    dx3: Float,
    dy3: Float
): PathBuilder

Add a cubic Bézier by adding a PathNode.CurveTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0). The cubic Bézier control and end points are defined by offsets relative to the last point.

Parameters
dx1: Float

The x offset of the first control point of the cubic curve, relative to the last path position

dy1: Float

The y offset of the first control point of the cubic curve, relative to the last path position

dx2: Float

The x offset of the second control point of the cubic curve, relative to the last path position

dy2: Float

The y offset of the second control point of the cubic curve, relative to the last path position

dx3: Float

The x offset of the end point of the cubic curve, relative to the last path position

dy3: Float

The y offset of the end point of the cubic curve, relative to the last path position

horizontalLineTo

fun horizontalLineTo(x: Float): PathBuilder

Add a line from the last point to the position (x, oy), where oy is the y coordinate of the last point, by adding a PathNode.HorizontalTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
x: Float

The x coordinate of the end of the line

horizontalLineToRelative

fun horizontalLineToRelative(dx: Float): PathBuilder

Add a line from the last point to the position (dx + ox, oy), where ox and oy are the x and y coordinates of the last point, by adding a PathNode.RelativeHorizontalTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
dx: Float

The x offset of the end of the line, relative to the last path position

lineTo

fun lineTo(x: Float, y: Float): PathBuilder

Add a line from the last point to the position (x, y) by adding a PathNode.LineTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
x: Float

The x coordinate of the end of the line

y: Float

The y coordinate of the end of the line

lineToRelative

fun lineToRelative(dx: Float, dy: Float): PathBuilder

Add a line from the last point to the offset (dx, dy) relative to the last point by adding a PathNode.RelativeLineTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
dx: Float

The x offset of the end of the line, relative to the last path position

dy: Float

The y offset of the end of the line, relative to the last path position

moveTo

fun moveTo(x: Float, y: Float): PathBuilder

Start a new contour at position (x, y) by adding a PathNode.MoveTo to nodes.

Parameters
x: Float

The x coordinate of the start of the new contour

y: Float

The y coordinate of the start of the new contour

moveToRelative

fun moveToRelative(dx: Float, dy: Float): PathBuilder

Start a new contour at the offset (dx, dy) relative to the last path position by adding a PathNode.RelativeMoveTo to nodes.

Parameters
dx: Float

The x offset of the start of the new contour, relative to the last path position

dy: Float

The y offset of the start of the new contour, relative to the last path position

quadTo

fun quadTo(x1: Float, y1: Float, x2: Float, y2: Float): PathBuilder

Add a quadratic Bézier from the last point to the position (x2, y2), approaching the control point (x1, y1), by adding a PathNode.QuadTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0).

Parameters
x1: Float

The x coordinate of the control point of the quadratic curve

y1: Float

The y coordinate of the control point of the quadratic curve

x2: Float

The x coordinate of the end point of the quadratic curve

y2: Float

The y coordinate of the end point of the quadratic curve

quadToRelative

fun quadToRelative(dx1: Float, dy1: Float, dx2: Float, dy2: Float): PathBuilder

Add a quadratic Bézier by adding a PathNode.RelativeQuadTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0). The control point and end point of the curve are defined by offsets relative to the last point.

Parameters
dx1: Float

The x offset of the control point of the quadratic curve, relative to the last path position

dy1: Float

The y offset of the control point of the quadratic curve, relative to the last path position

dx2: Float

The x offset of the end point of the quadratic curve, relative to the last path position

dy2: Float

The y offset of the end point of the quadratic curve, relative to the last path position

reflectiveCurveTo

fun reflectiveCurveTo(x1: Float, y1: Float, x2: Float, y2: Float): PathBuilder

Add a cubic Bézier from the last point to the position (x2, y2). The first control point is the reflection of the second control point of the previous command. If there is no previous command or the previous command is not a cubic Bézier, the first control point is set to the last path position. The second control point is defined by (x1, y1). Calling this method adds a PathNode.ReflectiveCurveTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0).

Parameters
x1: Float

The x coordinate of the second control point of the cubic curve

y1: Float

The y coordinate of the second control point of the cubic curve

x2: Float

The x coordinate of the end point of the cubic curve

y2: Float

The y coordinate of the end point of the cubic curve

reflectiveCurveToRelative

fun reflectiveCurveToRelative(dx1: Float, dy1: Float, dx2: Float, dy2: Float): PathBuilder

Add a cubic Bézier by adding a PathNode.RelativeReflectiveCurveTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0). The cubic Bézier second control point and end points are defined by offsets relative to the last point. The reflective nature of the curve is described in reflectiveCurveTo.

Parameters
dx1: Float

The x offset of the second control point of the cubic curve, relative to the last path position

dy1: Float

The y offset of the second control point of the cubic curve, relative to the last path position

dx2: Float

The x offset of the end point of the cubic curve, relative to the last path position

dy2: Float

The y offset of the end point of the cubic curve, relative to the last path position

reflectiveQuadTo

fun reflectiveQuadTo(x1: Float, y1: Float): PathBuilder

Add a quadratic Bézier from the last point to the position (x1, y1). The control point is the reflection of the control point of the previous command. If there is no previous command or the previous command is not a quadratic Bézier, the control point is set to the last path position. Calling this method adds a PathNode.ReflectiveQuadTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0).

Parameters
x1: Float

The x coordinate of the end point of the quadratic curve

y1: Float

The y coordinate of the end point of the quadratic curve

reflectiveQuadToRelative

fun reflectiveQuadToRelative(dx1: Float, dy1: Float): PathBuilder

Add a quadratic Bézier by adding a PathNode.RelativeReflectiveQuadTo to nodes. If no contour has been created by calling moveTo first, the origin of the curve is set to (0, 0). The quadratic Bézier end point is defined by an offset relative to the last point. The reflective nature of the curve is described in reflectiveQuadTo.

Parameters
dx1: Float

The x offset of the end point of the quadratic curve, relative to the last path position

dy1: Float

The y offset of the end point of the quadratic curve, relative to the last path position

verticalLineTo

fun verticalLineTo(y: Float): PathBuilder

Add a line from the last point to the position (ox, y), where ox is the x coordinate of the last point, by adding a PathNode.VerticalTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
y: Float

The y coordinate of the end of the line

verticalLineToRelative

fun verticalLineToRelative(dy: Float): PathBuilder

Add a line from the last point to the position (ox, dy + oy), where ox and oy are the x and y coordinates of the last point, by adding a PathNode.RelativeVerticalTo to nodes. If no contour has been created by calling moveTo first, the origin of the line is set to (0, 0).

Parameters
dy: Float

The y offset of the end of the line, relative to the last path position

Public properties

nodes

val nodesList<PathNode>

Returns the list of PathNode currently held in this builder.