David PHAM-VAN

Add PdfGraphics.drawBox()

... ... @@ -234,6 +234,11 @@ class PdfGraphics {
buf.putString(' re\n');
}
/// Draws a Rectangle
void drawBox(PdfRect box) {
drawRect(box.x, box.y, box.width, box.height);
}
/// Draws a Rounded Rectangle
void drawRRect(double x, double y, double w, double h, double rv, double rh) {
moveTo(x, y + rv);
... ...
... ... @@ -239,7 +239,7 @@ class Annotation extends SingleChildWidget {
void debugPaint(Context context) {
context.canvas
..setFillColor(PdfColors.pink)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..fillPath();
}
... ... @@ -367,7 +367,7 @@ class Outline extends Anchor {
void debugPaint(Context context) {
context.canvas
..setFillColor(PdfColors.pink100)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..fillPath();
}
... ...
... ... @@ -333,7 +333,7 @@ class Align extends SingleChildWidget {
context.canvas
..setStrokeColor(PdfColors.green)
..setLineWidth(1)
..drawRect(box.x, box.y, box.width, box.height);
..drawBox(box);
if (child == null) {
context.canvas.strokePath();
... ... @@ -498,7 +498,7 @@ class FittedBox extends SingleChildWidget {
context.canvas
..saveContext()
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..clipPath()
..setTransform(mat);
child.paint(context);
... ...
... ... @@ -383,7 +383,7 @@ class FixedAxis<T extends num> extends GridAxis {
case Axis.horizontal:
context.canvas
..setFillColor(PdfColors.grey300)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..fillPath();
break;
case Axis.vertical:
... ...
... ... @@ -97,12 +97,7 @@ class CartesianGrid extends ChartGrid {
void clip(Context context, PdfPoint size) {
context.canvas
..saveContext()
..drawRect(
gridBox.left,
gridBox.bottom,
gridBox.width,
gridBox.height,
)
..drawBox(gridBox)
..clipPath();
}
... ...
... ... @@ -27,7 +27,7 @@ class ClipRect extends SingleChildWidget {
context.canvas
..setStrokeColor(PdfColors.deepPurple)
..setLineWidth(1)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..strokePath();
}
... ... @@ -40,7 +40,7 @@ class ClipRect extends SingleChildWidget {
mat.translate(box.x, box.y);
context.canvas
..saveContext()
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..clipPath()
..setTransform(mat);
child.paint(context);
... ...
... ... @@ -197,7 +197,7 @@ class DecorationImage {
context.canvas
..saveContext()
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..clipPath()
..setTransform(mat)
..drawImage(_image, 0, 0, imageSize.x, imageSize.y)
... ... @@ -645,7 +645,7 @@ class BoxDecoration {
);
}
}
context.canvas.drawRect(box.x, box.y, box.width, box.height);
context.canvas.drawBox(box);
} else {
if (boxShadow != null) {
for (final s in boxShadow) {
... ... @@ -686,7 +686,7 @@ class BoxDecoration {
switch (shape) {
case BoxShape.rectangle:
if (borderRadius == null) {
context.canvas.drawRect(box.x, box.y, box.width, box.height);
context.canvas.drawBox(box);
} else {
borderRadius.paint(context, box);
}
... ...
... ... @@ -64,12 +64,7 @@ void _drawImageRect(PdfGraphics canvas, PdfImage image, PdfRect sourceRect,
canvas.saveContext();
canvas
..drawRect(
destinationRect.x,
destinationRect.y,
destinationRect.width,
destinationRect.height,
)
..drawBox(destinationRect)
..clipPath()
..drawImage(
image,
... ...
... ... @@ -63,7 +63,7 @@ class Placeholder extends Widget {
..lineTo(box.right, box.top)
..moveTo(box.x, box.top)
..lineTo(box.right, box.y)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..setLineWidth(strokeWidth)
..strokePath();
}
... ...
... ... @@ -135,7 +135,7 @@ abstract class Widget {
context.canvas
..setStrokeColor(PdfColors.purple)
..setLineWidth(1)
..drawRect(box.x, box.y, box.width, box.height)
..drawBox(box)
..strokePath();
}
}
... ...