Models a path that consists of lines and Bézier curves.
Remarks
Type Details
- yfiles module
- view-component
- yfiles-umd modules
- All view modules
- Legacy UMD name
- yfiles.geometry.GeneralPath
See Also
Constructors
Properties
Gets a value indicating whether this path contains elements other than an initial MOVE_TO.
Gets the last coordinates of the last path element.
Gets the number of PathType operations stored in this instance.
Methods
Appends the contents of the given path to this path.
Remarks
Parameters
A map of options to pass to the method.
- other - GeneralPath
- The path to append to this path.
- connect - boolean
- Whether to connect the path to the end of this path.
Appends parts of the contents of the given path to this path.
Remarks
Parameters
A map of options to pass to the method.
- other - GeneralPath
- The path to append to this path.
- beginIndex - number
- The first element to be copied from
other
, inclusively. - endIndex - number
- The last element to be copied from
other
, exclusively. - connect - boolean
- Whether to connect the path to the end of this path.
Appends an ellipse using the given bounding box to this instance.
Parameters
A map of options to pass to the method.
- bounds - IRectangle
- The bounds of the ellipse.
- connect - boolean
- Whether to initially lineTo the ellipses lowest point.
Appends an IOrientedRectangle to this path instance.
Parameters
A map of options to pass to the method.
- rectangle - IOrientedRectangle
- The IOrientedRectangle to get the coordinates from.
- connect - boolean
- Whether to use a lineTo to the anchor corner.
Appends a rectangle to this path instance.
Parameters
A map of options to pass to the method.
- rectangle - IRectangle
- The rectangle to get the coordinates from.
- connect - boolean
- Whether to use a lineTo to the upper left corner.
Checks whether the point lies inside the area that is described by this path instance.
Remarks
Parameters
A map of options to pass to the method.
- point - IPoint
- The coordinates of the point to test.
- eps - number
- The value to use for flattening Bézier curves during the test.
0.5
is the default value.
Returns
- ↪boolean
- Whether the point lies within the area described by this path.
Determines whether the area formed by this instance intersects with the area formed by the given path instance.
Parameters
A map of options to pass to the method.
- other - GeneralPath
- The other instance to check against.
- eps - number
- The epsilon value that is used for the accuracy with which the implementation should test Bézier curves within the path for intersections. The default value is
0.5
.
Returns
- ↪boolean
- Whether the filled area of this path intersects with the stroke or filled area of the given path.
Creates a clone of this instance, copying the path information to the new instance.
Creates a cursor for iterating over the elements of this path.
Remarks
Returns
- ↪GeneralPathCursor
- A cursor to iterate over this path.
createSmoothedPath
(smoothingLength: number, smoothingPolicy?: SmoothingPolicy, straightEnds?: boolean) : GeneralPathCreates a new path based on this one where corners are smoothed with a quadratic Bézier arc starting at smoothingLength
away from the corner.
Parameters
A map of options to pass to the method.
- smoothingLength - number
- Distance from the corner where the arc begins.
- smoothingPolicy - SmoothingPolicy
- A SmoothingPolicy value specifying how corners should be smoothed.
- straightEnds - boolean
- A value indicating whether the first and last segment of a path figure should end with a straight line segment, or whether the adjacent corner can be smoothed up to the very end of the path (if
smoothingLength
is large enough).
Returns
- ↪GeneralPath
- A new path, with its corners smoothed.
Creates an SVG path
element using the provided parameters.
Parameters
A map of options to pass to the method.
- transform - Matrix
- The matrix to apply to the path data.
Returns
- ↪SVGPathElement
- A path that displays this instance using the provided attributes.
Creates the data for a SVG path
element that corresponds to this instance with the provided transform.
Parameters
A map of options to pass to the method.
- transform - Matrix
- The transform to apply to the created data.
Returns
- ↪string
- The path data for an SVG
path
element that corresponds to this instance with the provided transform.
Creates a new GeneralPath that is a copy of this path with all geometry transformed using the supplied matrix.
Parameters
A map of options to pass to the method.
- transform - Matrix
- The matrix to multiply the geometry with.
Returns
- ↪GeneralPath
- A new path.
Crops the path after the position indicated by the cursor.
Remarks
Parameters
A map of options to pass to the method.
- cursor - GeneralPathCursor
- The cursor that depicts a position in this path.
Crops the path before the position indicated by the cursor.
Remarks
Parameters
A map of options to pass to the method.
- cursor - GeneralPathCursor
- The cursor that depicts a position in this path.
Appends a cubic Bézier curve to the path elements.
Remarks
Parameters
A map of options to pass to the method.
- c1x - number
- The x coordinate of the first Bézier control point.
- c1y - number
- The y coordinate of the first Bézier control point.
- c2x - number
- The x coordinate of the second Bézier control point.
- c2y - number
- The y coordinate of the second Bézier control point.
- x - number
- The x coordinate of the curve's end point.
- y - number
- The y coordinate of the curve's end point.
Appends a cubic Bézier curve to the path elements.
Remarks
Parameters
A map of options to pass to the method.
Finds an intersection point between a line and this GeneralPath.
Remarks
start + result * (end - start)
is an intersection point between the line and the path.Parameters
A map of options to pass to the method.
- start - Point
- The coordinates of the first point of the line.
- end - Point
- The coordinates of the second point of the line.
- eps - number
- The value to use for interpolating Bézier curves.
Returns
- ↪number
- The factor to calculate the intersection point or
double.PositiveInfinity
.
Finds the first intersection of a ray with this GeneralPath using a given epsilon for flattening Bézier curves contained in the path.
Remarks
(anchorX + result * rayX, anchorY + result * rayY)
is an intersection point between the ray and the path.Parameters
A map of options to pass to the method.
- anchor - Point
- The coordinates of the anchor point of the ray.
- direction - Point
- The coordinates of the direction vector of the ray.
- eps - number
- The epsilon value that is used for the accuracy with which the implementation should test Bézier curves within the path for intersections.
Returns
- ↪number
- The factor to calculate the intersection point or
double.PositiveInfinity
.
Creates a new path from this instance flattening all Bézier curves using the given epsilon.
Remarks
Parameters
A map of options to pass to the method.
- eps - number
- The maximum value the flattened path may diverge from the original path for the Bézier curve line interpolations.
Returns
- ↪GeneralPath
- A new path that does not contain Bézier curves.
Gets the bounds of a flattened version the path.
Remarks
0.0
, the path's Bézier curve segments are not flattened. Instead, this methods calculates exact tight bounds for Bézier curve segments in this case.Parameters
A map of options to pass to the method.
- eps - number
- The epsilon to use for the flattening operation.
Returns
- ↪Rect
- The bounds of the flattened path.
Calculates the bounds of this path and returns it.
Remarks
Returns
- ↪Rect
- A rectangle that describes the geometric bounds of this path.
See Also
Gets a point on this path instance at the given ratio.
Remarks
Parameters
A map of options to pass to the method.
- ratio - number
- A value between 0 and 1 inclusively that indicates a ratio from the beginning to the end of this path.
Returns
- ↪Point
- The coordinates of the point.
Gets the projection of p
onto the segment segmentIndex
Remarks
This method does not directly return the projection point, but the parameter ratio for the segment, or null
if no projection on the segment could be found within the interval [0,1]. To determine the actual projection point, you can use the ratio as input for getTangentForSegment
Note that this implementation still treats quadratic as linear segments.
Parameters
A map of options to pass to the method.
- p - Point
- The point which should be projected onto the segment
- segmentIndex - number
- The segment index. Not that only linear, cubic or close segments are considered.
Returns
- ↪number
- A ratio describing the projection onto the segement, or
null
if no such projection exists in the interval [0,1].
Gets the tangent on this path instance at the given ratio.
Remarks
Parameters
A map of options to pass to the method.
- ratio - number
- A value between 0 and 1 inclusively that indicates a ratio from the beginning to the end of this path.
Returns
- ↪Tangent
- The tangent, if any exists;
null
otherwise. The tangent vector may not be normalized.
Gets the tangent on this path instance at the segment and segment ratio.
Remarks
Parameters
A map of options to pass to the method.
- segmentIndex - number
- The segment index to determine a point at.
- ratio - number
- A value between 0 and 1 inclusively that indicates a ratio from the beginning to the end of the segment at segmentIndex for this path.
Returns
- ↪Tangent
- The tangent, if any exists;
null
otherwise. The tangent vector may not be normalized.
Determines whether a given GeneralPath instance can be considered equivalent to this one, that is, both represent the same path with the same sub-path types and coordinates.
Parameters
A map of options to pass to the method.
- path - GeneralPath
- The other GeneralPath instance to compare.
Returns
- ↪boolean
true
ifpath
and this instance have the same sub-path types and coordinates,false
if not.
Determines whether this path's stroked segments intersects with a given path.
Remarks
Parameters
A map of options to pass to the method.
- other - GeneralPath
- The other path to check against this path.
- eps - number
- The epsilon value that is used for the accuracy with which the implementation should test Bézier curves within the path for intersections.
Returns
- ↪boolean
- True if this path's stroked segments intersects the other path's stroked segments.
See Also
Checks whether this path intersects the given rectangle.
Remarks
Parameters
A map of options to pass to the method.
- rectangle - Rect
- The rectangle to test.
- eps - number
- The epsilon to use for fuzzy testing.
Returns
- ↪boolean
- Whether the path described by this instance intersects the rectangle.
Appends a LINE_TO operation to the path elements.
Remarks
Parameters
A map of options to pass to the method.
- x - number
- The x coordinate of the line's end point.
- y - number
- The y coordinate of the line's end point.
Performs a quick test to decide whether this path might intersect the clipping rectangle, provided the path would be rendered using stroke of the given width.
Remarks
Parameters
A map of options to pass to the method.
- clip - Rect
- The clip to check for intersection.
- width - number
- The width of the stroke.
Returns
- ↪boolean
false
if it is guaranteed that this instance would not intersect the given clip.
Appends a MOVE_TO operation to the path elements.
Remarks
Parameters
A map of options to pass to the method.
- x - number
- The next x coordinate.
- y - number
- The next y coordinate.
Tests whether the line of the path is hit at the given point using an epsilon for fuzzy hit testing.
Parameters
A map of options to pass to the method.
- point - IPoint
- The p coordinates of the point to test.
- eps - number
- The allowed distance from the point to the path that is considered a hit.
0.5
is the default value.
Returns
- ↪boolean
- Whether the point hits the path.
Adds the contents of the given path to the beginning of this path.
Remarks
Parameters
A map of options to pass to the method.
- other - GeneralPath
- The path to append to this path.
- connect - boolean
- Whether to connect the path to the end of this path.
Appends a quadratic Bézier curve to the path elements.
Remarks
Parameters
A map of options to pass to the method.
- cx - number
- The x coordinate of the Bézier control point.
- cy - number
- The y coordinate of the Bézier control point.
- x - number
- The x coordinate of the curve's end point.
- y - number
- The y coordinate of the curve's end point.
Appends a quadratic Bézier curve to the path elements.
Remarks
Parameters
A map of options to pass to the method.
Transforms this GeneralPath in place using the given transform.
Parameters
A map of options to pass to the method.
- transform - Matrix
- The matrix to multiply the geometry with.
Static Methods
getCubicSplitPoints
(cp0: Point, cp1: Point, cp2: Point, cp3: Point, splitBefore: boolean, t: number) : PointDetermines new control points for splitting a cubic Bézier segment.
Parameters
A map of options to pass to the method.
- cp0 - Point
- The start point of the segment
- cp1 - Point
- The first control point of the segment
- cp2 - Point
- The second control point of the segment
- cp3 - Point
- The control points of the cubic segment
- splitBefore - boolean
- A value indicating whether the new control points for the segment before or after the cut should be returned
- t - number
- The parameter for De Casteljau's algorithm to determine the splitting point in the interval [0..1].
Returns
- ↪Point[]
- An array of length 4 with the new start, end, and control points for the segment either preceding or following the desired split point.