Class Path

java.lang.Object
io.github.jwharm.cairobindings.Proxy
org.freedesktop.cairo.Path
All Implemented Interfaces:
Iterable<PathElement>

public class Path extends Proxy implements Iterable<PathElement>
A data structure for holding a path. This data structure serves as the return value for Context.copyPath() and Context.copyPathFlat() as well the input value for Context.appendPath(Path).

The Path class implements Iterable. The iterator loops through the cairo_path_data_t segments in native memory and returns PathElement instances. You can use record patterns in a switch expression to process the elements:

 Path path = cr.copyPath();
 for (PathElement element : path) {
     switch (element) {
         case PathElement.MoveTo(double x, double y) -> doMoveToThings(x, y);
         case PathElement.LineTo(double x, double y) -> doLineToThings(x, y);
         case PathElement.CurveTo(double x1, double y1, double x2, double y2, double x3, double y3) -> doCurveToThings(x1, y1, x2, y2, x3, y3);
         case PathElement.ClosePath() -> doClosePathThings();
     }
 }
 
Since:
1.0