Skip to content

Commit

Permalink
Fix drawShape Bézier curves
Browse files Browse the repository at this point in the history
  • Loading branch information
DavBfr committed Jan 27, 2019
1 parent f13cd8c commit ca2ef02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions pdf/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# 1.1.1
* Improve PdfPoint and PdfRect
* Change PdfColor.fromInt to const constructor
* Fix drawShape Bézier curves

# 1.1.0
* Rename classes to satisfy Dart conventions
Expand Down
14 changes: 6 additions & 8 deletions pdf/lib/src/graphics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ class PdfGraphics {
break;
case 'C': // cubic bezier, absolute
var len = 0;
while ((len + 1) * 6 <= points.length) {
while (len < points.length) {
curveTo(points[len + 0], points[len + 1], points[len + 2],
points[len + 3], points[len + 4], points[len + 5]);
len += 1;
len += 6;
}
lastPoint =
PdfPoint(points[points.length - 2], points[points.length - 1]);
Expand All @@ -307,7 +307,7 @@ class PdfGraphics {
break;
case 'c': // cubic bezier, relative
var len = 0;
while ((len + 1) * 6 <= points.length) {
while (len < points.length) {
points[len + 0] += lastPoint.x;
points[len + 1] += lastPoint.y;
points[len + 2] += lastPoint.x;
Expand All @@ -316,12 +316,10 @@ class PdfGraphics {
points[len + 5] += lastPoint.y;
curveTo(points[len + 0], points[len + 1], points[len + 2],
points[len + 3], points[len + 4], points[len + 5]);
len += 1;
lastPoint = PdfPoint(points[len + 4], points[len + 5]);
lastControl = PdfPoint(points[len + 2], points[len + 3]);
len += 6;
}
lastPoint =
PdfPoint(points[points.length - 2], points[points.length - 1]);
lastControl =
PdfPoint(points[points.length - 4], points[points.length - 3]);
break;
case 's': // smooth cubic bézier, relative
while (points.length >= 4) {
Expand Down

0 comments on commit ca2ef02

Please sign in to comment.