allow zooming on desktop when holding ctrl and scrolling

add prototype of selection mode, span up dashed rectangle
This commit is contained in:
2022-12-02 00:25:37 +01:00
parent 4899381510
commit 8e0cd05ded
5 changed files with 129 additions and 38 deletions

View File

@ -0,0 +1,25 @@
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;
}
}

View File

@ -0,0 +1,13 @@
class RingNumberProvider {
RingNumberProvider(this._vals);
final List<double> _vals;
int _idx = 0;
double get next {
if (_idx >= _vals.length) {
_idx = 0;
}
return _vals[_idx++];
}
}