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-05-11 13:30:19 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8893ad9ad896d8df1dad2dc4881ee3cdeffbf9f8
8893ad9a
1 parent
13638db9
Add DecorationImage to BoxDecoration
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
0 deletions
pdf/CHANGELOG.md
pdf/lib/widgets/container.dart
pdf/CHANGELOG.md
View file @
8893ad9
# 1.3.9
*
Fix Transform Widget alignment
*
Fix CustomPaint Widget size
*
Add DecorationImage to BoxDecoration
# 1.3.8
*
Add jpeg image loading function
...
...
pdf/lib/widgets/container.dart
View file @
8893ad9
...
...
@@ -86,6 +86,44 @@ class BoxBorder {
}
}
@immutable
class
DecorationImage
{
const
DecorationImage
(
{
@required
this
.
image
,
this
.
fit
=
BoxFit
.
cover
,
this
.
alignment
=
Alignment
.
center
})
:
assert
(
image
!=
null
),
assert
(
fit
!=
null
),
assert
(
alignment
!=
null
);
final
PdfImage
image
;
final
BoxFit
fit
;
final
Alignment
alignment
;
void
paintImage
(
Context
context
,
PdfRect
box
)
{
final
PdfPoint
imageSize
=
PdfPoint
(
image
.
width
.
toDouble
(),
image
.
height
.
toDouble
());
final
FittedSizes
sizes
=
applyBoxFit
(
fit
,
imageSize
,
box
.
size
);
final
double
scaleX
=
sizes
.
destination
.
x
/
sizes
.
source
.
x
;
final
double
scaleY
=
sizes
.
destination
.
y
/
sizes
.
source
.
y
;
final
PdfRect
sourceRect
=
alignment
.
inscribe
(
sizes
.
source
,
PdfRect
.
fromPoints
(
PdfPoint
.
zero
,
imageSize
));
final
PdfRect
destinationRect
=
alignment
.
inscribe
(
sizes
.
destination
,
box
);
final
Matrix4
mat
=
Matrix4
.
translationValues
(
destinationRect
.
x
,
destinationRect
.
y
,
0
)
..
scale
(
scaleX
,
scaleY
,
1
)
..
translate
(-
sourceRect
.
x
,
-
sourceRect
.
y
);
context
.
canvas
..
saveContext
()
..
drawRect
(
box
.
x
,
box
.
y
,
box
.
width
,
box
.
height
)
..
clipPath
()
..
setTransform
(
mat
)
..
drawImage
(
image
,
0
,
0
,
imageSize
.
x
,
imageSize
.
y
)
..
restoreContext
();
}
}
enum
BoxShape
{
circle
,
rectangle
}
@immutable
...
...
@@ -94,6 +132,7 @@ class BoxDecoration {
{
this
.
color
,
this
.
border
,
this
.
borderRadius
,
this
.
image
,
this
.
shape
=
BoxShape
.
rectangle
});
/// The color to fill in the background of the box.
...
...
@@ -101,6 +140,7 @@ class BoxDecoration {
final
BoxBorder
border
;
final
double
borderRadius
;
final
BoxShape
shape
;
final
DecorationImage
image
;
void
paintBackground
(
Context
context
,
PdfRect
box
)
{
assert
(
box
.
x
!=
null
);
...
...
@@ -150,11 +190,13 @@ class DecoratedBox extends SingleChildWidget {
super
.
paint
(
context
);
if
(
position
==
DecorationPosition
.
background
)
{
decoration
.
paintBackground
(
context
,
box
);
decoration
.
image
?.
paintImage
(
context
,
box
);
decoration
.
border
?.
paintBorders
(
context
,
box
);
}
paintChild
(
context
);
if
(
position
==
DecorationPosition
.
foreground
)
{
decoration
.
paintBackground
(
context
,
box
);
decoration
.
image
?.
paintImage
(
context
,
box
);
decoration
.
border
?.
paintBorders
(
context
,
box
);
}
}
...
...
Please
register
or
login
to post a comment