Package | com.yworks.canvas.drawing |
Class | public class GeneralPath |
Inheritance | GeneralPath Object |
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 | ||
append(other:GeneralPath, connect:Boolean):void
Appends the contents of the given path 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 | ||
cubicTo(c1x:Number, c1y:Number, c2x:Number, c2y:Number, x:Number, y:Number):void
Appends a cubic bezier curve to the path elements. | GeneralPath | ||
curveTo(cx:Number, cy:Number, x:Number, y:Number):void
Appends a quadratic bezier curve to the path elements. | GeneralPath | ||
equals(path:GeneralPath):Boolean | 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 | ||
getSegmentCount():int
Gets the number of segments in this path, i.e. | 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 | ||
isEmpty():Boolean
Returns whether this path contains elements other than an initial MoveTo. | 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.
public function get length():int
visible | property |
visible:Boolean
[read-only] Returns whether the path contains visible parts.
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.
Parameters
points:Array — An array of IPoint objects.
|
ArgumentError — 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
.
Parameters
points:Array — An array of IPoint objects.
|
ArgumentError — if the given array is not an array of IPoint 's.
|
append | () | method |
public function append(other:GeneralPath, connect:Boolean):void
Appends the contents of the given path to this path.
If connect
is true
, an initial PathType.MOVE_TO
in other
will be transformed into a PathType.LINE_TO
.
Parameters
other:GeneralPath — The path to append to this path.
| |
connect:Boolean — Whether to connect the path to the end of this path.
|
appendEllipse | () | method |
public function appendEllipse(bounds:IRectangle, connect:Boolean = false):void
Appends an ellipse using the given bounding box to this instance.
The ellipse is approximated using quadratic bezier curves.
Parameters
bounds: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):void
Appends a rectangle to the current path.
Parameters
rectangle: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, fill:IFill = null, stroke:IStroke = null):void
Draws this path on the given YGraphics
instance.
Parameters
g:YGraphics — YGraphics instance to draw on
| |
matrix:Matrix (default = null ) — transformation matrix
| |
fill:IFill (default = null ) — the fill to use for drawing the path
| |
stroke:IStroke (default = null ) — the stroke to use for drawing the path
|
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.
Parameters
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():void
Resets 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():PathCursor
Creates 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):void
Crops the path after the position indicated by the cursor.
This will remove all path operations that follow the position indicated by the cursor.
Parameters
cursor: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):void
Crops the path before the position indicated by the cursor.
This will remove all path operations that precede the position indicated by the cursor.
Parameters
cursor: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.
|
cubicTo | () | method |
public function cubicTo(c1x:Number, c1y:Number, c2x:Number, c2y:Number, x:Number, y:Number):void
Appends a cubic bezier curve to the path elements.
The cubic bezier curve is approximated by two quadratic bezier curves which are appended delegating to
curveTo
.
Parameters
c1x:Number — The x coordinate of the first bezier control point.
| |
c1y:Number — The y coordinate of the first bezier control point.
| |
c2x:Number — The x coordinate of the second bezier control point.
| |
c2y:Number — The y coordinate of the second 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.
|
See also
curveTo | () | method |
public function curveTo(cx:Number, cy:Number, x:Number, y:Number):void
Appends 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.
Parameters
cx: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.
|
equals | () | method |
findLineIntersection | () | method |
public function 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.
Parameters
lx1: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):IRectangle
Calculates 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.
Parameters
scratch: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.
|
getSegmentCount | () | method |
public function getSegmentCount():int
Gets the number of segments in this path, i.e. the number of lineTo
and close
operations.
int — The number of segments.
|
getTangent | () | method |
public function getTangent(ratio:Number, p:YPoint, t:YPoint):Boolean
Gets a point and the tangent on this path instance at the given ratio.
Note that this implementation still treats bezier curves as linear segments.
Parameters
ratio: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):GeneralPath
Returns a transformed version of this instance
Parameters
matrix: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):Boolean
Checks whether this path intersects the given rectangle.
This will yield false if the rectangle is fully contained within the area of the path.
Parameters
rx: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.
|
isEmpty | () | method |
public function isEmpty():Boolean
Returns whether this path contains elements other than an initial MoveTo.
ReturnsBoolean — Whether the path contains visible parts.
|
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.
Parameters
x: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.
Parameters
x:Number — The new x coordinate.
| |
y:Number — The new y coordinate.
|
pathContains | () | method |
public function 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.
Parameters
x: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.
|