Package ej.microvg
Class Path
- java.lang.Object
-
- ej.microvg.Path
-
public class Path extends Object
Represents a geometric paths consisting of straight line segments, quadratic curves, and cubic curves.
-
-
Constructor Summary
Constructors Constructor Description Path()Creates an empty path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the current contour.voidcubicTo(float x1, float y1, float x2, float y2, float x3, float y3)Adds a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3).voidcubicToRelative(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)Same ascubicTo(float, float, float, float, float, float), but the coordinates are considered relative to the current point on this contour.floatgetBottomBound()Gets the bottom bound of this path.floatgetLeftBound()Gets the left bound of this path.floatgetRightBound()Gets the right bound of this path.floatgetTopBound()Gets the top bound of this path.voidlineTo(float x, float y)Adds a line from the last point to the specified point (x,y).voidlineToRelative(float dx, float dy)Same aslineTo(float, float), but the coordinates are considered relative to the last point on this contour.voidmoveTo(float x, float y)Sets the beginning of the next contour to the point (x,y).voidmoveToRelative(float dx, float dy)Sets the beginning of the next contour relative to the last point on the previous contour.voidquadTo(float x1, float y1, float x2, float y2)Adds a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2).voidquadToRelative(float dx1, float dy1, float dx2, float dy2)Same asquadTo(float, float, float, float), but the coordinates are considered relative to the last point on this contour.voidreset()Resets the path to an empty one.voidsetOrigin(float dx, float dy)Sets the offset that will be applied to all the subsequent absolute points of the contour.
-
-
-
Method Detail
-
reset
public void reset()
Resets the path to an empty one.The origin is also reset to (0,0).
-
moveTo
public void moveTo(float x, float y)Sets the beginning of the next contour to the point (x,y).- Parameters:
x- the x-coordinate of the start of a new contoury- the y-coordinate of the start of a new contour
-
moveToRelative
public void moveToRelative(float dx, float dy)Sets the beginning of the next contour relative to the last point on the previous contour. If there is no previous contour, this is treated the same asmoveTo(float, float).- Parameters:
dx- the amount to add to the x-coordinate of the end of the previous contour, to specify the start of a new contourdy- the amount to add to the y-coordinate of the end of the previous contour, to specify the start of a new contour
-
lineTo
public void lineTo(float x, float y)Adds a line from the last point to the specified point (x,y). If nomoveTo(float, float)call has been made for this contour, the first point is automatically set to (0,0).- Parameters:
x- the x-coordinate of the end of a liney- the y-coordinate of the end of a line
-
lineToRelative
public void lineToRelative(float dx, float dy)Same aslineTo(float, float), but the coordinates are considered relative to the last point on this contour. If there is no previous point, then amoveTo(0,0)is inserted automatically.- Parameters:
dx- the amount to add to the x-coordinate of the previous point on this contour, to specify a linedy- the amount to add to the y-coordinate of the previous point on this contour, to specify a line
-
quadTo
public void quadTo(float x1, float y1, float x2, float y2)Adds a quadratic bezier from the last point, approaching control point (x1,y1), and ending at (x2,y2). If nomoveTo(float, float)call has been made for this contour, the first point is automatically set to (0,0).- Parameters:
x1- the x-coordinate of the control point on a quadratic curvey1- the y-coordinate of the control point on a quadratic curvex2- the x-coordinate of the end point on a quadratic curvey2- the y-coordinate of the end point on a quadratic curve
-
quadToRelative
public void quadToRelative(float dx1, float dy1, float dx2, float dy2)Same asquadTo(float, float, float, float), but the coordinates are considered relative to the last point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.- Parameters:
dx1- the amount to add to the x-coordinate of the last point on this contour, for the control point of a quadratic curvedy1- the amount to add to the y-coordinate of the last point on this contour, for the control point of a quadratic curvedx2- the amount to add to the x-coordinate of the last point on this contour, for the end point of a quadratic curvedy2- the amount to add to the y-coordinate of the last point on this contour, for the end point of a quadratic curve
-
cubicTo
public void cubicTo(float x1, float y1, float x2, float y2, float x3, float y3)Adds a cubic bezier from the last point, approaching control points (x1,y1) and (x2,y2), and ending at (x3,y3). If nomoveTo(float, float)call has been made for this contour, the first point is automatically set to (0,0).- Parameters:
x1- the x-coordinate of the 1st control point on a cubic curvey1- the y-coordinate of the 1st control point on a cubic curvex2- the x-coordinate of the 2nd control point on a cubic curvey2- the y-coordinate of the 2nd control point on a cubic curvex3- the x-coordinate of the end point on a cubic curvey3- the y-coordinate of the end point on a cubic curve
-
cubicToRelative
public void cubicToRelative(float dx1, float dy1, float dx2, float dy2, float dx3, float dy3)Same ascubicTo(float, float, float, float, float, float), but the coordinates are considered relative to the current point on this contour. If there is no previous point, then a moveTo(0,0) is inserted automatically.- Parameters:
dx1- the x-coordinate of the 1st control point on a cubic curvedy1- the y-coordinate of the 1st control point on a cubic curvedx2- the x-coordinate of the 2nd control point on a cubic curvedy2- the y-coordinate of the 2nd control point on a cubic curvedx3- the x-coordinate of the end point on a cubic curvedy3- the y-coordinate of the end point on a cubic curve
-
close
public void close()
Closes the current contour. If the current point is not equal to the first point of the contour, a line segment is automatically added.
-
setOrigin
public void setOrigin(float dx, float dy)Sets the offset that will be applied to all the subsequent absolute points of the contour.- Parameters:
dx- the amount in the x direction to offset the subsequent pointsdy- the amount in the y direction to offset the subsequent points
-
getLeftBound
public float getLeftBound()
Gets the left bound of this path.If this path does not contain any point, all bounds are equal to 0.
- Returns:
- the left bound of this path
-
getRightBound
public float getRightBound()
Gets the right bound of this path.If this path does not contain any point, all bounds are equal to 0.
- Returns:
- the right bound of this path
-
getTopBound
public float getTopBound()
Gets the top bound of this path.If this path does not contain any point, all bounds are equal to 0.
- Returns:
- the top bound of this path
-
getBottomBound
public float getBottomBound()
Gets the bottom bound of this path.If this path does not contain any point, all bounds are equal to 0.
- Returns:
- the bottom bound of this path
-
-