notes/lib/canvas/path/path_transform.dart

26 lines
624 B
Dart
Raw Permalink Normal View History

import 'dart:ui';
import 'ring_number_provider.dart';
extension DashPath on Path {
// creates a new dashed path with the given intervals
Path dashPath(RingNumberProvider dashArray) {
final Path dest = Path();
for (final PathMetric metric in computeMetrics()) {
double distance = .0;
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;
}
}