Showing
10 changed files
with
19 additions
and
24 deletions
| @@ -234,6 +234,11 @@ class PdfGraphics { | @@ -234,6 +234,11 @@ class PdfGraphics { | ||
| 234 | buf.putString(' re\n'); | 234 | buf.putString(' re\n'); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | + /// Draws a Rectangle | ||
| 238 | + void drawBox(PdfRect box) { | ||
| 239 | + drawRect(box.x, box.y, box.width, box.height); | ||
| 240 | + } | ||
| 241 | + | ||
| 237 | /// Draws a Rounded Rectangle | 242 | /// Draws a Rounded Rectangle |
| 238 | void drawRRect(double x, double y, double w, double h, double rv, double rh) { | 243 | void drawRRect(double x, double y, double w, double h, double rv, double rh) { |
| 239 | moveTo(x, y + rv); | 244 | moveTo(x, y + rv); |
| @@ -239,7 +239,7 @@ class Annotation extends SingleChildWidget { | @@ -239,7 +239,7 @@ class Annotation extends SingleChildWidget { | ||
| 239 | void debugPaint(Context context) { | 239 | void debugPaint(Context context) { |
| 240 | context.canvas | 240 | context.canvas |
| 241 | ..setFillColor(PdfColors.pink) | 241 | ..setFillColor(PdfColors.pink) |
| 242 | - ..drawRect(box.x, box.y, box.width, box.height) | 242 | + ..drawBox(box) |
| 243 | ..fillPath(); | 243 | ..fillPath(); |
| 244 | } | 244 | } |
| 245 | 245 | ||
| @@ -367,7 +367,7 @@ class Outline extends Anchor { | @@ -367,7 +367,7 @@ class Outline extends Anchor { | ||
| 367 | void debugPaint(Context context) { | 367 | void debugPaint(Context context) { |
| 368 | context.canvas | 368 | context.canvas |
| 369 | ..setFillColor(PdfColors.pink100) | 369 | ..setFillColor(PdfColors.pink100) |
| 370 | - ..drawRect(box.x, box.y, box.width, box.height) | 370 | + ..drawBox(box) |
| 371 | ..fillPath(); | 371 | ..fillPath(); |
| 372 | } | 372 | } |
| 373 | 373 |
| @@ -333,7 +333,7 @@ class Align extends SingleChildWidget { | @@ -333,7 +333,7 @@ class Align extends SingleChildWidget { | ||
| 333 | context.canvas | 333 | context.canvas |
| 334 | ..setStrokeColor(PdfColors.green) | 334 | ..setStrokeColor(PdfColors.green) |
| 335 | ..setLineWidth(1) | 335 | ..setLineWidth(1) |
| 336 | - ..drawRect(box.x, box.y, box.width, box.height); | 336 | + ..drawBox(box); |
| 337 | 337 | ||
| 338 | if (child == null) { | 338 | if (child == null) { |
| 339 | context.canvas.strokePath(); | 339 | context.canvas.strokePath(); |
| @@ -498,7 +498,7 @@ class FittedBox extends SingleChildWidget { | @@ -498,7 +498,7 @@ class FittedBox extends SingleChildWidget { | ||
| 498 | 498 | ||
| 499 | context.canvas | 499 | context.canvas |
| 500 | ..saveContext() | 500 | ..saveContext() |
| 501 | - ..drawRect(box.x, box.y, box.width, box.height) | 501 | + ..drawBox(box) |
| 502 | ..clipPath() | 502 | ..clipPath() |
| 503 | ..setTransform(mat); | 503 | ..setTransform(mat); |
| 504 | child.paint(context); | 504 | child.paint(context); |
| @@ -383,7 +383,7 @@ class FixedAxis<T extends num> extends GridAxis { | @@ -383,7 +383,7 @@ class FixedAxis<T extends num> extends GridAxis { | ||
| 383 | case Axis.horizontal: | 383 | case Axis.horizontal: |
| 384 | context.canvas | 384 | context.canvas |
| 385 | ..setFillColor(PdfColors.grey300) | 385 | ..setFillColor(PdfColors.grey300) |
| 386 | - ..drawRect(box.x, box.y, box.width, box.height) | 386 | + ..drawBox(box) |
| 387 | ..fillPath(); | 387 | ..fillPath(); |
| 388 | break; | 388 | break; |
| 389 | case Axis.vertical: | 389 | case Axis.vertical: |
| @@ -97,12 +97,7 @@ class CartesianGrid extends ChartGrid { | @@ -97,12 +97,7 @@ class CartesianGrid extends ChartGrid { | ||
| 97 | void clip(Context context, PdfPoint size) { | 97 | void clip(Context context, PdfPoint size) { |
| 98 | context.canvas | 98 | context.canvas |
| 99 | ..saveContext() | 99 | ..saveContext() |
| 100 | - ..drawRect( | ||
| 101 | - gridBox.left, | ||
| 102 | - gridBox.bottom, | ||
| 103 | - gridBox.width, | ||
| 104 | - gridBox.height, | ||
| 105 | - ) | 100 | + ..drawBox(gridBox) |
| 106 | ..clipPath(); | 101 | ..clipPath(); |
| 107 | } | 102 | } |
| 108 | 103 |
| @@ -27,7 +27,7 @@ class ClipRect extends SingleChildWidget { | @@ -27,7 +27,7 @@ class ClipRect extends SingleChildWidget { | ||
| 27 | context.canvas | 27 | context.canvas |
| 28 | ..setStrokeColor(PdfColors.deepPurple) | 28 | ..setStrokeColor(PdfColors.deepPurple) |
| 29 | ..setLineWidth(1) | 29 | ..setLineWidth(1) |
| 30 | - ..drawRect(box.x, box.y, box.width, box.height) | 30 | + ..drawBox(box) |
| 31 | ..strokePath(); | 31 | ..strokePath(); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| @@ -40,7 +40,7 @@ class ClipRect extends SingleChildWidget { | @@ -40,7 +40,7 @@ class ClipRect extends SingleChildWidget { | ||
| 40 | mat.translate(box.x, box.y); | 40 | mat.translate(box.x, box.y); |
| 41 | context.canvas | 41 | context.canvas |
| 42 | ..saveContext() | 42 | ..saveContext() |
| 43 | - ..drawRect(box.x, box.y, box.width, box.height) | 43 | + ..drawBox(box) |
| 44 | ..clipPath() | 44 | ..clipPath() |
| 45 | ..setTransform(mat); | 45 | ..setTransform(mat); |
| 46 | child.paint(context); | 46 | child.paint(context); |
| @@ -197,7 +197,7 @@ class DecorationImage { | @@ -197,7 +197,7 @@ class DecorationImage { | ||
| 197 | 197 | ||
| 198 | context.canvas | 198 | context.canvas |
| 199 | ..saveContext() | 199 | ..saveContext() |
| 200 | - ..drawRect(box.x, box.y, box.width, box.height) | 200 | + ..drawBox(box) |
| 201 | ..clipPath() | 201 | ..clipPath() |
| 202 | ..setTransform(mat) | 202 | ..setTransform(mat) |
| 203 | ..drawImage(_image, 0, 0, imageSize.x, imageSize.y) | 203 | ..drawImage(_image, 0, 0, imageSize.x, imageSize.y) |
| @@ -645,7 +645,7 @@ class BoxDecoration { | @@ -645,7 +645,7 @@ class BoxDecoration { | ||
| 645 | ); | 645 | ); |
| 646 | } | 646 | } |
| 647 | } | 647 | } |
| 648 | - context.canvas.drawRect(box.x, box.y, box.width, box.height); | 648 | + context.canvas.drawBox(box); |
| 649 | } else { | 649 | } else { |
| 650 | if (boxShadow != null) { | 650 | if (boxShadow != null) { |
| 651 | for (final s in boxShadow) { | 651 | for (final s in boxShadow) { |
| @@ -686,7 +686,7 @@ class BoxDecoration { | @@ -686,7 +686,7 @@ class BoxDecoration { | ||
| 686 | switch (shape) { | 686 | switch (shape) { |
| 687 | case BoxShape.rectangle: | 687 | case BoxShape.rectangle: |
| 688 | if (borderRadius == null) { | 688 | if (borderRadius == null) { |
| 689 | - context.canvas.drawRect(box.x, box.y, box.width, box.height); | 689 | + context.canvas.drawBox(box); |
| 690 | } else { | 690 | } else { |
| 691 | borderRadius.paint(context, box); | 691 | borderRadius.paint(context, box); |
| 692 | } | 692 | } |
| @@ -64,12 +64,7 @@ void _drawImageRect(PdfGraphics canvas, PdfImage image, PdfRect sourceRect, | @@ -64,12 +64,7 @@ void _drawImageRect(PdfGraphics canvas, PdfImage image, PdfRect sourceRect, | ||
| 64 | 64 | ||
| 65 | canvas.saveContext(); | 65 | canvas.saveContext(); |
| 66 | canvas | 66 | canvas |
| 67 | - ..drawRect( | ||
| 68 | - destinationRect.x, | ||
| 69 | - destinationRect.y, | ||
| 70 | - destinationRect.width, | ||
| 71 | - destinationRect.height, | ||
| 72 | - ) | 67 | + ..drawBox(destinationRect) |
| 73 | ..clipPath() | 68 | ..clipPath() |
| 74 | ..drawImage( | 69 | ..drawImage( |
| 75 | image, | 70 | image, |
| @@ -63,7 +63,7 @@ class Placeholder extends Widget { | @@ -63,7 +63,7 @@ class Placeholder extends Widget { | ||
| 63 | ..lineTo(box.right, box.top) | 63 | ..lineTo(box.right, box.top) |
| 64 | ..moveTo(box.x, box.top) | 64 | ..moveTo(box.x, box.top) |
| 65 | ..lineTo(box.right, box.y) | 65 | ..lineTo(box.right, box.y) |
| 66 | - ..drawRect(box.x, box.y, box.width, box.height) | 66 | + ..drawBox(box) |
| 67 | ..setLineWidth(strokeWidth) | 67 | ..setLineWidth(strokeWidth) |
| 68 | ..strokePath(); | 68 | ..strokePath(); |
| 69 | } | 69 | } |
| @@ -135,7 +135,7 @@ abstract class Widget { | @@ -135,7 +135,7 @@ abstract class Widget { | ||
| 135 | context.canvas | 135 | context.canvas |
| 136 | ..setStrokeColor(PdfColors.purple) | 136 | ..setStrokeColor(PdfColors.purple) |
| 137 | ..setLineWidth(1) | 137 | ..setLineWidth(1) |
| 138 | - ..drawRect(box.x, box.y, box.width, box.height) | 138 | + ..drawBox(box) |
| 139 | ..strokePath(); | 139 | ..strokePath(); |
| 140 | } | 140 | } |
| 141 | } | 141 | } |
-
Please register or login to post a comment