Package limn.graphics
Class Path2D
java.lang.Object
limn.graphics.Path2D
Mutable 2D path: move/line/quadratic/cubic segments and closed subpaths, in
logical points. Curves are consumed via
flatten(float, limn.graphics.Path2D.Flattened), which subdivides
them adaptively into line segments within a given tolerance; backends never
see curves.
V1 limitations (documented, revisited with the widget set): filling uses each closed subpath independently, with no even-odd/non-zero interaction between subpaths, so paths with holes render as overlapping fills; self-intersecting subpaths are unsupported.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceReceives the flattened (curve-free) form of a path.static interfaceReceives a path as it was built: its moves, lines, curves and closes, in order and in the path's own coordinates. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclose()Closes the current subpath (straight line back to its starting point).copy()A path of its own with the same segments: what a caller that keeps a path past the call it was handed in takes, since the one it was handed may be reset and reused for the next frame.cubicTo(float c1x, float c1y, float c2x, float c2y, float x, float y) Cubic Bézier to(x,y)with control points(c1x,c1y)and(c2x,c2y).voidflatten(float tolerance, Path2D.Flattened out) Replays this path with curves adaptively subdivided so that no flattened segment deviates from the true curve by more thantolerance(same units as the path coordinates).voidforEach(Path2D.Visitor out) Replays this path as it was built, curves as curves.booleanisEmpty()Whether the path has nothing to draw.lineTo(float x, float y) Extends the current subpath; a no-op before the firstmoveTo(float, float).moveTo(float x, float y) Starts a new subpath at a point, in logical points.quadTo(float cx, float cy, float x, float y) Quadratic Bézier to(x,y)with control point(cx,cy).voidreset()Clears every subpath, keeping the allocated capacity so the path can be reused per frame.
-
Constructor Details
-
Path2D
public Path2D()
-
-
Method Details
-
moveTo
Starts a new subpath at a point, in logical points. -
lineTo
Extends the current subpath; a no-op before the firstmoveTo(float, float). -
quadTo
Quadratic Bézier to(x,y)with control point(cx,cy). -
cubicTo
Cubic Bézier to(x,y)with control points(c1x,c1y)and(c2x,c2y). -
close
Closes the current subpath (straight line back to its starting point). -
isEmpty
public boolean isEmpty()Whether the path has nothing to draw. -
reset
public void reset()Clears every subpath, keeping the allocated capacity so the path can be reused per frame. -
forEach
Replays this path as it was built, curves as curves.- Parameters:
out- receives each segment in order
-
copy
A path of its own with the same segments: what a caller that keeps a path past the call it was handed in takes, since the one it was handed may be reset and reused for the next frame.- Returns:
- the copy
-
flatten
Replays this path with curves adaptively subdivided so that no flattened segment deviates from the true curve by more thantolerance(same units as the path coordinates).
-