Class RasterPath
A shape made of straight lines and quadratic and cubic Bezier curves, for
RasterGraphics.fill(RasterPath) and RasterGraphics.draw(RasterPath).
A path is a list of subpaths, each started by moveTo(double, double).
Filling closes every subpath implicitly; stroking draws a subpath closed
only after closePath().
The static factories build the common shapes. Angles are in degrees,
counterclockwise from three o'clock, as on screen with y pointing down
(so a positive extent turns toward the top).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(RasterPath other) Appends every subpath of another path to this one.static RasterPatharc(double x, double y, double w, double h, double startDeg, double extentDeg, int type) Creates an arc of the ellipse inscribed in a rectangle.Closes the current subpath with a line back to its start.curveTo(double c1x, double c1y, double c2x, double c2y, double x, double y) Adds a cubic Bezier curve.static RasterPathellipse(double x, double y, double w, double h) Creates the ellipse inscribed in a rectangle.booleanisEmpty()Returns true when the path has no segments.lineTo(double x, double y) Adds a straight line to a point.moveTo(double x, double y) Starts a new subpath at a point.static RasterPathpolygon(double[] xs, double[] ys, int n) Creates a closed polygon.static RasterPathpolyline(double[] xs, double[] ys, int n) Creates an open chain of lines.quadTo(double cx, double cy, double x, double y) Adds a quadratic Bezier curve.static RasterPathrect(double x, double y, double w, double h) Creates a rectangle.static RasterPathroundRect(double x, double y, double w, double h, double arcW, double arcH) Creates a rectangle with elliptical corners.
-
Field Details
-
ARC_OPEN
public static final int ARC_OPENAn arc drawn alone, both ends open.- See Also:
-
ARC_CHORD
public static final int ARC_CHORDAn arc closed by the straight line between its ends.- See Also:
-
ARC_PIE
public static final int ARC_PIEAn arc closed through the center, a pie slice.- See Also:
-
-
Constructor Details
-
RasterPath
public RasterPath()
-
-
Method Details
-
moveTo
Starts a new subpath at a point.
Parameters
x: xy: y
Returns
this path
-
lineTo
Adds a straight line to a point.
Parameters
x: xy: y
Returns
this path
-
quadTo
Adds a quadratic Bezier curve.
Parameters
cx: control point xcy: control point yx: end xy: end y
Returns
this path
-
curveTo
Adds a cubic Bezier curve.
Parameters
c1x: first control point xc1y: first control point yc2x: second control point xc2y: second control point yx: end xy: end y
Returns
this path
-
closePath
Closes the current subpath with a line back to its start.
Returns
this path
-
isEmpty
public boolean isEmpty()Returns true when the path has no segments. -
polygon
Creates a closed polygon.
Parameters
xs: x of each vertexys: y of each vertexn: number of vertices to use
Returns
the path
-
polyline
Creates an open chain of lines.
Parameters
xs: x of each vertexys: y of each vertexn: number of vertices to use
Returns
the path
-
rect
Creates a rectangle.
Parameters
x: lefty: topw: widthh: height
Returns
the path
-
roundRect
public static RasterPath roundRect(double x, double y, double w, double h, double arcW, double arcH) Creates a rectangle with elliptical corners.
Parameters
x: lefty: topw: widthh: heightarcW: horizontal diameter of a cornerarcH: vertical diameter of a corner
Returns
the path
-
ellipse
Creates the ellipse inscribed in a rectangle.
Parameters
x: lefty: topw: widthh: height
Returns
the path
-
arc
public static RasterPath arc(double x, double y, double w, double h, double startDeg, double extentDeg, int type) Creates an arc of the ellipse inscribed in a rectangle.
Parameters
x: left of the ellipse's boundsy: top of the ellipse's boundsw: width of the ellipseh: height of the ellipsestartDeg: start angle in degreesextentDeg: angular extent in degrees, negative for clockwisetype:ARC_OPEN,ARC_CHORDorARC_PIE
Returns
the path
-
append
Appends every subpath of another path to this one.
Parameters
other: the path to append
Returns
this path
-