Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
dart_pdf
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
David PHAM-VAN
2019-02-01 18:00:13 -0500
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b89d885afe167686cfb6427b2458b1d6a835e431
b89d885a
1 parent
b03d41a1
Implement rounded rect
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
19 deletions
pdf/CHANGELOG.md
pdf/lib/src/graphics.dart
pdf/CHANGELOG.md
View file @
b89d885
...
...
@@ -2,6 +2,7 @@
*
Change license to Apache 2.0
*
Improve PdfRect
*
Add support for CMYK, HSL anf HSV colors
*
Implement rounded rect
# 1.1.1
*
Improve PdfPoint and PdfRect
...
...
pdf/lib/src/graphics.dart
View file @
b89d885
...
...
@@ -19,6 +19,9 @@ part of pdf;
enum
PdfLineCap
{
joinMiter
,
joinRound
,
joinBevel
}
class
PdfGraphics
{
/// Ellipse 4-spline magic number
static
const
_m4
=
0.551784
;
/// Graphic context number
var
_context
=
0
;
...
...
@@ -122,28 +125,14 @@ class PdfGraphics {
}
void
drawEllipse
(
double
x
,
double
y
,
double
r1
,
double
r2
)
{
// The best 4-spline magic number
double
m4
=
0.551784
;
// Starting point
moveTo
(
x
,
y
-
r2
);
buf
.
putNumList
(
<
double
>[
x
+
m4
*
r1
,
y
-
r2
,
x
+
r1
,
y
-
m4
*
r2
,
x
+
r1
,
y
]);
buf
.
putString
(
" c
\n
"
);
buf
.
putNumList
(
<
double
>[
x
+
r1
,
y
+
m4
*
r2
,
x
+
m4
*
r1
,
y
+
r2
,
x
,
y
+
r2
]);
buf
.
putString
(
" c
\n
"
);
buf
.
putNumList
(
<
double
>[
x
-
m4
*
r1
,
y
+
r2
,
x
-
r1
,
y
+
m4
*
r2
,
x
-
r1
,
y
]);
buf
.
putString
(
" c
\n
"
);
buf
.
putNumList
(
<
double
>[
x
-
r1
,
y
-
m4
*
r2
,
x
-
m4
*
r1
,
y
-
r2
,
x
,
y
-
r2
]);
buf
.
putString
(
" c
\n
"
);
curveTo
(
x
+
_m4
*
r1
,
y
-
r2
,
x
+
r1
,
y
-
_m4
*
r2
,
x
+
r1
,
y
);
curveTo
(
x
+
r1
,
y
+
_m4
*
r2
,
x
+
_m4
*
r1
,
y
+
r2
,
x
,
y
+
r2
);
curveTo
(
x
-
_m4
*
r1
,
y
+
r2
,
x
-
r1
,
y
+
_m4
*
r2
,
x
-
r1
,
y
);
curveTo
(
x
-
r1
,
y
-
_m4
*
r2
,
x
-
_m4
*
r1
,
y
-
r2
,
x
,
y
-
r2
);
}
/// We override Graphics.drawRect as it doesn't join the 4 lines.
/// Also, Pdf provides us with a Rectangle operator, so we will use that.
/// Draws a Rectangle
///
/// @param x coordinate
/// @param y coordinate
...
...
@@ -159,6 +148,27 @@ class PdfGraphics {
buf
.
putString
(
" re
\n
"
);
}
/// Draws a Rounded Rectangle
///
/// @param x coordinate
/// @param y coordinate
/// @param w width
/// @param h height
/// @param rh horizontal radius
/// @param rv vertical radius
void
drawRRect
(
double
x
,
double
y
,
double
w
,
double
h
,
double
rv
,
double
rh
)
{
moveTo
(
x
,
y
+
rv
);
curveTo
(
x
,
y
-
_m4
*
rv
+
rv
,
x
-
_m4
*
rh
+
rh
,
y
,
x
+
rh
,
y
);
lineTo
(
x
+
w
-
rh
,
y
);
curveTo
(
x
+
_m4
*
rh
+
w
-
rh
,
y
,
x
+
w
,
y
-
_m4
*
rv
+
rv
,
x
+
w
,
y
+
rv
);
lineTo
(
x
+
w
,
y
+
h
-
rv
);
curveTo
(
x
+
w
,
y
+
_m4
*
rv
+
h
-
rv
,
x
+
_m4
*
rh
+
w
-
rh
,
y
+
h
,
x
+
w
-
rh
,
y
+
h
);
lineTo
(
x
+
rh
,
y
+
h
);
curveTo
(
x
-
_m4
*
rh
+
rh
,
y
+
h
,
x
,
y
+
_m4
*
rv
+
h
-
rv
,
x
,
y
+
h
-
rv
);
lineTo
(
x
,
y
+
rv
);
}
/// This draws a string.
///
/// @param x coordinate
...
...
Please
register
or
login
to post a comment