| Package | com.yworks.canvas.drawing |
| Class | public class GeneralPath |
This class models a virtual pen that can be moved across the world coordinate system and which can be used to draw lines and curves.
| Property | Defined by | ||
|---|---|---|---|
| length : int [read-only]
Gets the number of drawing operations stored in this instance.
| GeneralPath | ||
| visible : Boolean [read-only]
Returns whether the path contains visible parts.
| GeneralPath | ||
| Method | Defined by | ||
|---|---|---|---|
|
Constructor.
| GeneralPath | ||
|
addLines(points:Array):void
Appends a polyline given by an array of
IPoints's to this path. | GeneralPath | ||
|
addPolygon(points:Array):void
Appends a polygon given by an array of
IPoints's to this path. | GeneralPath | ||
|
appendEllipse(bounds:IRectangle, connect:Boolean = false):void
Appends an ellipse using the given bounding box to this instance.
| GeneralPath | ||
|
appendRectangle(rectangle:IRectangle, connect:Boolean):void
Appends a rectangle to the current path.
| GeneralPath | ||
|
Draws this path on the given
YGraphics instance. | GeneralPath | ||
|
areaContains(x:Number, y:Number, eps:Number = 0.5):Boolean
Checks whether the point lies inside the area that is described by this path instance.
| GeneralPath | ||
|
clear():void
Resets this path to be an empty path.
| GeneralPath | ||
|
close():void
Appends a
PathType.CLOSE operation to the path elements, creating a line
to the last PathType.MOVE_TO position. | GeneralPath | ||
|
Creates a cursor for iterating over the elements of this path.
| GeneralPath | ||
|
Crops the path after the position indicated by the cursor.
| GeneralPath | ||
|
Crops the path before the position indicated by the cursor.
| GeneralPath | ||
|
curveTo(cx:Number, cy:Number, x:Number, y:Number):void
Appends a quadratic bezier curve to the path elements.
| GeneralPath | ||
|
findLineIntersection(lx1:Number, ly1:Number, lx2:Number, ly2:Number, eps:Number = 0.5):Number
Finds an intersection point between a line and this general path using a given epsilon
for flattening bezier curves.
| GeneralPath | ||
|
Calculates the bounds of this path and returns it.
| GeneralPath | ||
|
Gets a point and the tangent on this path instance at the given ratio.
| GeneralPath | ||
|
getTransformed(matrix:Matrix):GeneralPath
Returns a transformed version of this instance
| GeneralPath | ||
|
intersects(rx:Number, ry:Number, rw:Number, rh:Number, eps:Number):Boolean
Checks whether this path intersects the given rectangle.
| GeneralPath | ||
|
lineTo(x:Number, y:Number):void
Appends a
PathType.LINE_TO operation to the path elements. | GeneralPath | ||
|
moveTo(x:Number, y:Number):void
Appends a
PathType.MOVE_TO operation to the path elements. | GeneralPath | ||
|
pathContains(x:Number, y:Number, eps:Number):Boolean
Tests whether the line of the path is hit at the given point using an epsilon
for fuzzy hit testing.
| GeneralPath | ||
| length | property |
length:int [read-only]Gets the number of drawing operations stored in this instance.
Implementation public function get length():int
| visible | property |
visible:Boolean [read-only]Returns whether the path contains visible parts.
Implementation public function get visible():Boolean
| GeneralPath | () | constructor |
public function GeneralPath()Constructor.
| addLines | () | method |
public function addLines(points:Array):void
Appends a polyline given by an array of IPoints's to this path.
This performs a PathType.MOVE_TO to the first point in the array,
appends PathType.LINE_TO's to the remaining points.
It will not close the path.
points:Array — An array of IPoint objects.
|
— if the given array is not an array of IPoint's.
|
| addPolygon | () | method |
public function addPolygon(points:Array):void
Appends a polygon given by an array of IPoints's to this path.
This performs a PathType.MOVE_TO to the first point in the array,
appends PathType.LINE_TO's to the remaining points and finally
appends a PathType.CLOSE.
points:Array — An array of IPoint objects.
|
— if the given array is not an array of IPoint's.
|
| appendEllipse | () | method |
public function appendEllipse(bounds:IRectangle, connect:Boolean = false):voidAppends an ellipse using the given bounding box to this instance.
The ellipse is approximated using quadratic bezier curves.
Parametersbounds:IRectangle — The bounds of the ellipse.
|
|
connect:Boolean (default = false) — Whether to initially lineTo(IPoint) the ellipses lowest point.
|
| appendRectangle | () | method |
public function appendRectangle(rectangle:IRectangle, connect:Boolean):voidAppends a rectangle to the current path.
Parametersrectangle:IRectangle — The rectangle to append.
|
|
connect:Boolean — true if the path should be connected with the
upper left corner of the rectangle (x, y)
|
| apply | () | method |
public function apply(g:YGraphics, matrix:Matrix = null):void
Draws this path on the given YGraphics instance.
g:YGraphics — YGraphics instance to draw on
|
|
matrix:Matrix (default = null) — transformation matrix
|
| areaContains | () | method |
public function areaContains(x:Number, y:Number, eps:Number = 0.5):Boolean
Checks whether the point lies inside the area that is described by this path instance.
Note that this will only work as expected for closed paths.
The epsilon is used for internally flattening bezier curves.
x:Number — The x coordinate of the point to test.
|
|
y:Number — The y coordinate of the point to test.
|
|
eps:Number (default = 0.5) — The value to use for flattening bezier curves during the test.
|
Boolean — Whether the point lies within the area described by this path.
|
| clear | () | method |
public function clear():voidResets this path to be an empty path.
| close | () | method |
public function close():void
Appends a PathType.CLOSE operation to the path elements, creating a line
to the last PathType.MOVE_TO position.
This draws a line from the current end point to the last moveTo( Number, Number ) position,
closing the current sub path.
| createCursor | () | method |
public function createCursor():PathCursorCreates a cursor for iterating over the elements of this path.
The cursor is fail-fast, i.e. if the path's structure is modified after the construction of the cursor any cursor operation will fail.
ReturnsPathCursor —
A cursor to iterator over this path.
|
| cropAfter | () | method |
public function cropAfter(cursor:PathCursor, cropPoint:IPoint = null):voidCrops the path after the position indicated by the cursor.
This will remove all path operations that follow the position indicated by the cursor.
Parameterscursor:PathCursor — The cursor that depicts a position in this path.
|
|
cropPoint:IPoint (default = null) — If not null, the path will end with a line to the given point after cropping.
|
| cropBefore | () | method |
public function cropBefore(cursor:PathCursor, cropPoint:IPoint = null):voidCrops the path before the position indicated by the cursor.
This will remove all path operations that precede the position indicated by the cursor.
Parameterscursor:PathCursor — The cursor that depicts a position in this path.
|
|
cropPoint:IPoint (default = null) — If not null, the path will start with the
given point after cropping.
|
| curveTo | () | method |
public function curveTo(cx:Number, cy:Number, x:Number, y:Number):voidAppends a quadratic bezier curve to the path elements.
This draws a quadratic bezier curve from the current end point to the given position using the given control point.
Parameterscx:Number — The x coordinate of the bezier control point.
|
|
cy:Number — The y coordinate of the bezier control point.
|
|
x:Number — The x coordinate of the curve's end point.
|
|
y:Number — The y coordinate of the curve's end point.
|
| findLineIntersection | () | method |
public function findLineIntersection(lx1:Number, ly1:Number, lx2:Number, ly2:Number, eps:Number = 0.5):NumberFinds an intersection point between a line and this general path using a given epsilon for flattening bezier curves.
Parameterslx1:Number — The x coordinate of the first point of the line.
|
|
ly1:Number — The y coordinate of the first point of the line.
|
|
lx2:Number — The x coordinate of the second point of the line.
|
|
ly2:Number — The y coordinate of the second point of the line.
|
|
eps:Number (default = 0.5) — The epsilon value that is used for the accuracy with which the implementation
should test curves within the path for intersections.
|
Number — The factor to calculate the intersection point or Infinity.
|
| getBounds | () | method |
public function getBounds(scratch:IMutableRectangle):IRectangleCalculates the bounds of this path and returns it.
This will not yield tight bounds if the path contains curves. The bounds are calculated using the union of all points and control points contained in this path.
Parametersscratch:IMutableRectangle — A scratch variable that may be used by the implementation to place the result in.
|
IRectangle —
A rectangle that describes the geometric bounds of this path.
|
| getTangent | () | method |
public function getTangent(ratio:Number, p:YPoint, t:YPoint):BooleanGets a point and the tangent on this path instance at the given ratio.
Note that this implementation still treats bezier curves as linear segments.
Parametersratio:Number — A value between 0 and 1 inclusively that indicates a ratio from
the beginning to the end of this path.
|
|
p:YPoint — The point to set.
|
|
t:YPoint — The tangent vector to set.
|
Boolean — true, if the tangent was found.
|
| getTransformed | () | method |
public function getTransformed(matrix:Matrix):GeneralPathReturns a transformed version of this instance
Parametersmatrix:Matrix — The matrix to be applied to this path.
|
GeneralPath |
| intersects | () | method |
public function intersects(rx:Number, ry:Number, rw:Number, rh:Number, eps:Number):BooleanChecks whether this path intersects the given rectangle.
This will yield false if the rectangle is fully contained within the area of the path.
Parametersrx:Number — The x coordinate of the upper left corner of the rectangle.
|
|
ry:Number — The y coordinate of the upper left corner of the rectangle.
|
|
rw:Number — The width of the rectangle.
|
|
rh:Number — The height of the rectangle.
|
|
eps:Number — The epsilon to use for fuzzy testing.
|
Boolean — Whether the path described by this instance intersects the rectangle.
|
| lineTo | () | method |
public function lineTo(x:Number, y:Number):void
Appends a PathType.LINE_TO operation to the path elements.
This draws a line from the current end point to the given position.
Parametersx:Number — The x coordinate of the line's endpoint.
|
|
y:Number — The y coordinate of the line's endpoint.
|
| moveTo | () | method |
public function moveTo(x:Number, y:Number):void
Appends a PathType.MOVE_TO operation to the path elements.
This moves the pen to a new position without drawing a line.
Parametersx:Number — The new x coordinate.
|
|
y:Number — The new y coordinate.
|
| pathContains | () | method |
public function pathContains(x:Number, y:Number, eps:Number):BooleanTests whether the line of the path is hit at the given point using an epsilon for fuzzy hit testing.
Parametersx:Number — The x coordinate of the point to test.
|
|
y:Number — The y coordinate of the point to test.
|
|
eps:Number — The allowed distance from the point to the path that is considered a hit.
|
Boolean — Whether the point hits the path.
|