notes/lib/canvas/path/path_transform.dart
lukas-heiligenbrunner 8e0cd05ded allow zooming on desktop when holding ctrl and scrolling
add prototype of selection mode, span up dashed rectangle
2022-12-02 00:25:37 +01:00

26 lines
624 B
Dart

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;
}
}