Showing
4 changed files
with
24 additions
and
1 deletions
@@ -30,6 +30,8 @@ class PdfPoint { | @@ -30,6 +30,8 @@ class PdfPoint { | ||
30 | 30 | ||
31 | const PdfPoint(this.x, this.y); | 31 | const PdfPoint(this.x, this.y); |
32 | 32 | ||
33 | + static const zero = PdfPoint(0.0, 0.0); | ||
34 | + | ||
33 | @override | 35 | @override |
34 | String toString() => "PdfPoint($x, $y)"; | 36 | String toString() => "PdfPoint($x, $y)"; |
35 | } | 37 | } |
@@ -22,6 +22,8 @@ part of pdf; | @@ -22,6 +22,8 @@ part of pdf; | ||
22 | class PdfRect { | 22 | class PdfRect { |
23 | final double x, y, w, h; | 23 | final double x, y, w, h; |
24 | 24 | ||
25 | + static const zero = PdfRect(0.0, 0.0, 0.0, 0.0); | ||
26 | + | ||
25 | const PdfRect(this.x, this.y, this.w, this.h); | 27 | const PdfRect(this.x, this.y, this.w, this.h); |
26 | 28 | ||
27 | factory PdfRect.fromLTRB( | 29 | factory PdfRect.fromLTRB( |
@@ -29,6 +31,10 @@ class PdfRect { | @@ -29,6 +31,10 @@ class PdfRect { | ||
29 | return PdfRect(left, top, right - left, bottom - top); | 31 | return PdfRect(left, top, right - left, bottom - top); |
30 | } | 32 | } |
31 | 33 | ||
34 | + factory PdfRect.fromPoints(PdfPoint offset, PdfPoint size) { | ||
35 | + return PdfRect(offset.x, offset.y, size.x, size.y); | ||
36 | + } | ||
37 | + | ||
32 | double get l => x; | 38 | double get l => x; |
33 | double get b => y; | 39 | double get b => y; |
34 | double get r => x + w; | 40 | double get r => x + w; |
@@ -36,4 +42,16 @@ class PdfRect { | @@ -36,4 +42,16 @@ class PdfRect { | ||
36 | 42 | ||
37 | @override | 43 | @override |
38 | String toString() => "PdfRect($x, $y, $w, $h)"; | 44 | String toString() => "PdfRect($x, $y, $w, $h)"; |
45 | + | ||
46 | + PdfRect operator *(double factor) { | ||
47 | + return PdfRect(x * factor, y * factor, w * factor, h * factor); | ||
48 | + } | ||
49 | + | ||
50 | + PdfPoint get offset => PdfPoint(x, y); | ||
51 | + PdfPoint get size => PdfPoint(w, h); | ||
52 | + | ||
53 | + PdfPoint get topLeft => PdfPoint(x, y); | ||
54 | + PdfPoint get topRight => PdfPoint(r, y); | ||
55 | + PdfPoint get bottomLeft => PdfPoint(x, t); | ||
56 | + PdfPoint get bottomRight => PdfPoint(r, t); | ||
39 | } | 57 | } |
@@ -2,7 +2,7 @@ name: pdf | @@ -2,7 +2,7 @@ name: pdf | ||
2 | author: David PHAM-VAN <dev.nfet.net@gmail.com> | 2 | author: David PHAM-VAN <dev.nfet.net@gmail.com> |
3 | description: A pdf producer for Dart. It can create pdf files for both web or flutter. | 3 | description: A pdf producer for Dart. It can create pdf files for both web or flutter. |
4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf | 4 | homepage: https://github.com/DavBfr/dart_pdf/tree/master/pdf |
5 | -version: 1.1.0 | 5 | +version: 1.1.1 |
6 | 6 | ||
7 | environment: | 7 | environment: |
8 | sdk: ">=1.8.0 <3.0.0" | 8 | sdk: ">=1.8.0 <3.0.0" |
-
Please register or login to post a comment