David PHAM-VAN

Improve BoxBorder correctness

... ... @@ -12,6 +12,7 @@
- Document.save() now returns a Future
- Add Widget.draw() to paint any widget on a canvas
- Improve Chart labels
- Improve BoxBorder correctness
## 1.13.0
... ...
... ... @@ -582,6 +582,7 @@ class PdfGraphics {
/// Set line joint miter limit, applies if the
void setMiterLimit(double limit) {
assert(limit >= 1.0);
PdfNum(limit).output(buf);
buf.putString(' M\n');
}
... ...
... ... @@ -14,6 +14,8 @@
* limitations under the License.
*/
import 'dart:math' as math;
import 'package:pdf/pdf.dart';
import 'package:xml/xml.dart';
... ... @@ -225,7 +227,7 @@ class SvgPath extends SvgOperation {
..drawShape(d)
..setLineCap(brush.strokeLineCap)
..setLineJoin(brush.strokeLineJoin)
..setMiterLimit(brush.strokeMiterLimit)
..setMiterLimit(math.max(1.0, brush.strokeMiterLimit))
..setLineDashPattern(
brush.strokeDashArray, brush.strokeDashOffset.toInt())
..setLineWidth(brush.strokeWidth.sizeValue)
... ...
... ... @@ -87,6 +87,8 @@ abstract class BoxBorder {
BorderSide side, BorderRadius borderRadius) {
_setStyle(context, side.style);
context.canvas
..setLineJoin(PdfLineJoin.miter)
..setMiterLimit(4)
..setStrokeColor(side.color)
..setLineWidth(side.width);
borderRadius.paint(context, box);
... ... @@ -98,6 +100,8 @@ abstract class BoxBorder {
Context context, PdfRect box, BorderSide side) {
_setStyle(context, side.style);
context.canvas
..setLineJoin(PdfLineJoin.miter)
..setMiterLimit(4)
..setStrokeColor(side.color)
..setLineWidth(side.width)
..drawBox(box)
... ... @@ -254,7 +258,10 @@ class Border extends BoxBorder {
assert(borderRadius == null,
'A borderRadius can only be given for a uniform Border.');
context.canvas.setLineCap(PdfLineCap.square);
context.canvas
..setLineCap(PdfLineCap.square)
..setMiterLimit(4)
..setLineJoin(PdfLineJoin.miter);
if (top.style != BorderStyle.none) {
BoxBorder._setStyle(context, top.style);
... ...