Table of Contents

Class PathSegment

Namespace
Northwoods.Go
Assembly
Northwoods.GoDiagram.WinForms.dll

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

public class PathSegment
Inheritance
PathSegment
Inherited Members

Remarks

The very first point is given by the StartX and StartY properties. After the first segment the beginning point of the next segment is the same as the end point of the previous segment. For most types of PathSegments the end point of the segment is given by EndX and EndY.

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

Constructors

PathSegment(SegmentType, double, double, double, double, double, double, bool)

Constructs a segment that goes nowhere unless you specify some Points.

The very first point of a path is specified in the containing PathFigure by its StartX and StartY properties.

public PathSegment(SegmentType type = SegmentType.Line, double ex = 0, double ey = 0, double x1 = 0, double y1 = 0, double x2 = 0, double y2 = 0, bool clockwise = false)

Parameters

type SegmentType

if not supplied, the default PathSegment type is 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 <xref href="Northwoods.Go.SegmentType.Line?text=Line" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.Line, ex, ey)`
   - **ex, ey** describe the end point

 If the type is <xref href="Northwoods.Go.SegmentType.QuadraticBezier?text=QuadraticBezier" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.QuadraticBezier, ex, ey, x1, y1)`
   - **ex, ey** describe the end point
   - **x1, y1** describe the only control point

 If the type is <xref href="Northwoods.Go.SegmentType.Bezier?text=Bezier" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.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 <xref href="Northwoods.Go.SegmentType.Arc?text=Arc" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.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 <xref href="Northwoods.Go.SegmentType.SvgArc?text=SvgArc" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.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 <xref href="Northwoods.Go.PathSegment.XAxisRotation" data-throw-if-not-resolved="false"></xref> (number in degrees)
   - **largeArcFlag** describes the <xref href="Northwoods.Go.PathSegment.IsLargeArc" data-throw-if-not-resolved="false"></xref> (true or false)
   - **clockwiseFlag** describes the <xref href="Northwoods.Go.PathSegment.IsClockwiseArc" data-throw-if-not-resolved="false"></xref> (true or false).

 If the type is <xref href="Northwoods.Go.SegmentType.Move?text=Move" data-throw-if-not-resolved="false"></xref> it needs the following arguments:

 `(SegmentType.Move, ex, ey)`
   - **ex, ey** describe the next starting point
ex double

optional: the X coordinate of the end point, or the startAngle of an Arc.

ey double

optional: the Y coordinate of the end point, or the sweepAngle of an Arc.

x1 double

optional: the X coordinate of the first bezier control point, or the centerX of an Arc, or the radiusX of an SvgArc.

y1 double

optional: the Y coordinate of the first bezier control point, or the centerY of an Arc, or the radiusY of an SvgArc.

x2 double

optional: the X coordinate of the second cubic bezier control point, or the radiusX of an Arc, or the xAxisRotation of an SvgArc.

y2 double

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.

clockwise bool

optional: whether an SvgArc goes clockwise or counterclockwise.

Remarks

The segment type must be one of the following values: Line, Bezier, QuadraticBezier, Arc, SvgArc. You will want to add a new instance of a PathSegment to the Segments list of a PathFigure.

Properties

CenterX

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

public double CenterX { get; set; }

Property Value

double

CenterY

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

public double CenterY { get; set; }

Property Value

double

EndX

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

public double EndX { get; set; }

Property Value

double

EndY

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

public double EndY { get; set; }

Property Value

double

IsClockwiseArc

Gets or sets the clockwise-flag for a PathSegment of type SvgArc. SVG Arcs specify a radius and an endpoint, and are always a portion of an ellipse.

public bool IsClockwiseArc { get; set; }

Property Value

bool

Remarks

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

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

public bool IsClosed { get; set; }

Property Value

bool

IsLargeArc

Gets or sets the large-arc-flag for a PathSegment of type SvgArc. SVG Arcs specify a radius and an endpoint, and are always a portion of an ellipse.

public bool IsLargeArc { get; set; }

Property Value

bool

Remarks

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

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

public double Point1X { get; set; }

Property Value

double

Point1Y

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

public double Point1Y { get; set; }

Property Value

double

Point2X

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

public double Point2X { get; set; }

Property Value

double

Point2Y

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

public double Point2Y { get; set; }

Property Value

double

RadiusX

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

public double RadiusX { get; set; }

Property Value

double

RadiusY

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

public double RadiusY { get; set; }

Property Value

double

StartAngle

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

public double StartAngle { get; set; }

Property Value

double

SweepAngle

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

public double SweepAngle { get; set; }

Property Value

double

Type

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

public SegmentType Type { get; set; }

Property Value

SegmentType

XAxisRotation

Gets or sets the X-axis rotation for a PathSegment of type SvgArc. 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.

public double XAxisRotation { get; set; }

Property Value

double

Methods

Close()

Closes the path after this PathSegment

public PathSegment Close()

Returns

PathSegment

returns this PathSegment.

Copy()

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

public PathSegment Copy()

Returns

PathSegment