Class PathSegment

A PathSegment represents a straight line or curved segment of a path between two or more points that are part of a PathFigure.

A PathSegment must not be modified once its containing PathFigure's Geometry has been assigned to a Shape.

Constructor Summary Details

Name Description
PathSegment(type, ex, ey, x1, y1, x2, y2, clockwise)

Constructs a segment that goes nowhere unless you specify some Points.More... The segment type must be one of the following values: PathSegment.Line, PathSegment.Bezier, PathSegment.QuadraticBezier, PathSegment.Arc, PathSegment.SvgArc. You will want to add a new instance of a PathSegment to the PathFigure.segments list of a PathFigure.

Parameters:
{EnumValue=} type
if not supplied, the default PathSegment type is PathSegment.Line. But if the type is supplied, one must also provide the endpoint X and Y values, either as arguments in this constructor or by setting the endX and endY properties. If the type is QuadraticBezier, the X1 and Y1 control point values must both be supplied. If the type is Bezier, X1, Y1, X2, and Y2 control point values must all be supplied.

If the type is Line it needs the following arguments:

(go.PathSegment.Line, ex, ey)

  • ex, ey describe the end point

If the type is QuadraticBezier it needs the following arguments:

(go.PathSegment.QuadraticBezier, ex, ey, x1, y1)

  • ex, ey describe the end point
  • x1, y1 describe the only control point

If the type is Bezier it needs the following arguments:

(go.PathSegment.Bezier, ex, ey, x1, y1, x2, y2)

  • ex, ey describe the end point
  • x1, y1 describe the first control point
  • x2, y2 describe the second control point

If the type is Arc it needs the following arguments:

(go.PathSegment.Arc, startAngle, sweepAngle, centerX, centerY, radiusX, radiusY)

  • startAngle describes the start angle, in degrees
  • sweepAngle describes the sweep angle, in degrees
  • centerX, centerY describe the center point
  • radiusX, radiusY describe the radiusX and radiusY

If the type is SvgArc it needs the following arguments:

(go.PathSegment.SvgArc, ex, ey, radiusX, radiusY, xAxisRotation, largeArcFlag, clockwiseFlag)

They are in the same order as arcs in SVG path strings, except the endpoint x and y values come first, not last.

  • ex, ey describe the endpoint
  • radiusX, radiusY describe the radius
  • xAxisRotation describes the xAxisRotation (number in degrees)
  • largeArcFlag describes the isLargeArc (true or false)
  • clockwiseFlag describes the isClockwiseArc (true or false).
{number=} ex
optional: the X coordinate of the end point, or the startAngle of an Arc.
{number=} ey
optional: the Y coordinate of the end point, or the sweepAngle of an Arc.
{number=} x1
optional: the X coordinate of the first bezier control point, or the centerX of an Arc, or the radiusX of an SvgArc.
{number=} y1
optional: the Y coordinate of the first bezier control point, or the centerY of an Arc, or the radiusY of an SvgArc.
{number=} x2
optional: the X coordinate of the second cubic bezier control point, or the radiusX of an Arc, or the xAxisRotation of an SvgArc.
{number|boolean=} y2
optional: the Y coordinate of the second cubic bezier control point, or the radiusY of an Arc, or whether this is the larger arc of an SvgArc.
{boolean=} clockwise
optional: whether an SvgArc goes clockwise or counterclockwise.

Properties Summary Details

Name, Value Type Description
centerX
{number}

Gets or sets the center X value of the Arc for a PathSegment of type Arc.

centerY
{number}

Gets or sets the center Y value of the Arc for a PathSegment of type Arc.

endX
{number}

Gets or sets the X coordinate of the end point for all types of PathSegment except Arc.More... The default value is zero.

endY
{number}

Gets or sets the Y coordinate of the end point for all types of PathSegment except Arc.More... The default value is zero.

isClockwiseArc
{boolean}

Gets or sets the clockwise-flag for a PathSegment of type SvgArc.More... SVG Arcs specify a radius and an endpoint, and are always a portion of an ellipse. The parameters allow for two potential ellipses and four potential arcs. A clockwise-flag set to true will use one of the two possible positive-angle arcs, and false will use one of the two negative-angle arcs. Which arc is chosen (small or large) depends on the value of isLargeArc. For more information see the visual examples in the SVG Arc specification (w3.org)

isClosed
{boolean}

Gets or sets whether the path is closed after this PathSegment.More... Default value is false.

isLargeArc
{boolean}

Gets or sets the large-arc-flag for a PathSegment of type SvgArc.More... SVG Arcs specify a radius and an endpoint, and are always a portion of an ellipse. The parameters allow for two potential ellipses and four potential arcs. A large-arc-flag set to true will choose the larger of the two arc sweeps. Which way the arc sweeps (positive angle or negative angle) depends on the value of isClockwiseArc For more information see the visual examples in the SVG Arc specification (w3.org)

point1X
{number}

Gets or sets the X value of the first control point for a PathSegment of type Bezier or QuadraticBezier.

point1Y
{number}

Gets or sets the Y value of the first control point for a PathSegment of type Bezier or QuadraticBezier.

point2X
{number}

Gets or sets the X value of the second control point for a PathSegment of type cubic Bezier.

point2Y
{number}

Gets or sets the Y value of the second control point for a PathSegment of type cubic Bezier.

radiusX
{number}

Gets or sets the X value of the radius for a PathSegment of type Arc or SvgArc.More... Value must be a positive number.

radiusY
{number}

Gets or sets the Y value of the radius for a PathSegment of type Arc or SvgArc.More... Value must be a positive number. At the current time the value of radiusY must be the same as the value of radiusX.

startAngle
{number}

Gets or sets the starting angle for a PathSegment of type Arc.More... Value must within the range: (0 <= value < 360).

sweepAngle
{number}

Gets or sets the length of angle in degrees, or amount of arc to "sweep" for a PathSegment of type Arc.More... Must be between -360 and 360, inclusive.

type
{EnumValue}

Gets or sets the type of the PathSegment.More... The value must be one of the following: PathSegment.Line, PathSegment.Bezier, PathSegment.QuadraticBezier, PathSegment.Arc, PathSegment.Move, PathSegment.Arc, and PathSegment.SvgArc.

xAxisRotation
{number}

Gets or sets the X-axis rotation for a PathSegment of type SvgArc.More... X-axis rotation is used to rotate the ellipse that the arc is created from, and must be between 0 and 360 degrees. Default is 0.

Method Summary Details

Name, Return Type Description
close()

Closes the path after this PathSegment

Returns:
{PathSegment} returns this PathSegment.
copy()

Create a copy of this PathSegment, of the same type and with the same point values.

Returns:
{PathSegment}

Constants Summary Details

Name Description
Arc {EnumValue}

For drawing an arc segment, a value for PathSegment.type.

Bezier {EnumValue}

For drawing a cubic bezier segment, a value for PathSegment.type.

Line {EnumValue}

For drawing a straight line segment, a value for PathSegment.type.

Move {EnumValue}

For beginning a new subpath, a value for PathSegment.type.

QuadraticBezier {EnumValue}

For drawing a quadratic bezier segment, a value for PathSegment.type.

SvgArc 1.1 {EnumValue}

For drawing an SVG arc segment, a value for PathSegment.type; see: SVG Arc specification (w3.org)