allow zooming on desktop when holding ctrl and scrolling
add prototype of selection mode, span up dashed rectangle
This commit is contained in:
		
							
								
								
									
										25
									
								
								lib/canvas/path/path_transform.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/canvas/path/path_transform.dart
									
									
									
									
									
										Normal 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;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								lib/canvas/path/ring_number_provider.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								lib/canvas/path/ring_number_provider.dart
									
									
									
									
									
										Normal 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++];
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user