Skip to content

Commit

Permalink
fix: treat two equal points as a single point
Browse files Browse the repository at this point in the history
  • Loading branch information
adil192 committed Nov 6, 2023
1 parent 40fa73e commit 0bb5a99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "2.0.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
7 changes: 6 additions & 1 deletion lib/src/get_stroke_points.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ List<StrokePoint> getStrokePoints(
// Find the interpolation level between points.
final t = 0.15 + (1 - streamline) * 0.85;

// Clone array of points and fill in missing p.
// Clone array of points and fill in missing pressure values.
final pts =
points.map((p) => p.copyWith(pressure: p.pressure ?? 0.5)).toList();

// If we have two equal points, treat them as a single point.
if (pts.length == 2 && pts.first == pts.last) {
pts.removeLast();
}

// Add extra points between the two, to help avoid "dash" lines
// for strokes with tapered start and ends. Don't mutate the
// input array!
Expand Down
Binary file modified test/example_inputs/two_equal_points.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0bb5a99

Please sign in to comment.