dashPath function
Path
dashPath(
- Path source, {
- required CircularIntervalList<
double> dashArray, - DashOffset? dashOffset,
Creates a new path that is drawn from the segments of source
.
Dash intervals are controled by the dashArray
- see CircularIntervalList
for examples.
dashOffset
specifies an initial starting point for the dashing.
Passing a source
that is an empty path will return an empty path.
Implementation
Path dashPath(
Path source, {
required CircularIntervalList<double> dashArray,
DashOffset? dashOffset,
}) {
assert(dashArray != null); // ignore: unnecessary_null_comparison
dashOffset = dashOffset ?? const DashOffset.absolute(0.0);
final Path dest = Path();
for (final PathMetric metric in source.computeMetrics()) {
double distance = dashOffset._calculate(metric.length);
bool draw = true;
while (distance < metric.length) {
final double len = dashArray.next;
if (draw) {
dest.addPath(metric.extractPath(distance, distance + len), Offset.zero);
}
distance += len;
draw = !draw;
}
}
return dest;
}