Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class RasterPath
- Object
- 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).
Fields
public static final int ARC_OPEN = 0 | An arc drawn alone, both ends open. |
public static final int ARC_CHORD = 1 | An arc closed by the straight line between its ends. |
public static final int ARC_PIE = 2 | An arc closed through the center, a pie slice. |
Constructors
public RasterPath() |
Methods
Inherited methods
Field details
ARC_OPEN
public static final int ARC_OPEN = 0An arc drawn alone, both ends open.
ARC_CHORD
public static final int ARC_CHORD = 1An arc closed by the straight line between its ends.
ARC_PIE
public static final int ARC_PIE = 2An arc closed through the center, a pie slice.
Constructor details
RasterPath
public RasterPath()Method details
moveTo
public RasterPath moveTo(double x, double y)Starts a new subpath at a point.
Parameters
xdouble- x
ydouble- y
Returns
this path
lineTo
public RasterPath lineTo(double x, double y)Adds a straight line to a point.
Parameters
xdouble- x
ydouble- y
Returns
this path
quadTo
public RasterPath quadTo(double cx, double cy, double x, double y)Adds a quadratic Bezier curve.
Parameters
cxdouble- control point x
cydouble- control point y
xdouble- end x
ydouble- end y
Returns
this path
curveTo
public RasterPath curveTo(double c1x, double c1y, double c2x, double c2y, double x, double y)Adds a cubic Bezier curve.
Parameters
c1xdouble- first control point x
c1ydouble- first control point y
c2xdouble- second control point x
c2ydouble- second control point y
xdouble- end x
ydouble- end y
Returns
this path
closePath
public RasterPath 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
public static RasterPath polygon(double[] xs, double[] ys, int n)Creates a closed polygon.
Parameters
xsdouble[]- x of each vertex
ysdouble[]- y of each vertex
nint- number of vertices to use
Returns
the path
polyline
public static RasterPath polyline(double[] xs, double[] ys, int n)Creates an open chain of lines.
Parameters
xsdouble[]- x of each vertex
ysdouble[]- y of each vertex
nint- number of vertices to use
Returns
the path
rect
public static RasterPath rect(double x, double y, double w, double h)Creates a rectangle.
Parameters
xdouble- left
ydouble- top
wdouble- width
hdouble- 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
xdouble- left
ydouble- top
wdouble- width
hdouble- height
arcWdouble- horizontal diameter of a corner
arcHdouble- vertical diameter of a corner
Returns
the path
ellipse
public static RasterPath ellipse(double x, double y, double w, double h)Creates the ellipse inscribed in a rectangle.
Parameters
xdouble- left
ydouble- top
wdouble- width
hdouble- 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
xdouble- left of the ellipse’s bounds
ydouble- top of the ellipse’s bounds
wdouble- width of the ellipse
hdouble- height of the ellipse
startDegdouble- start angle in degrees
extentDegdouble- angular extent in degrees, negative for clockwise
typeintARC_OPEN,ARC_CHORDorARC_PIE
Returns
the path
append
public RasterPath append(RasterPath other)Appends every subpath of another path to this one.
Parameters
otherRasterPath- the path to append
Returns
this path