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
2021-04-02 13:09:56 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ef6944acefe2325a78b7f0b3d3840c481612db8c
ef6944ac
1 parent
56f15055
Improve GraphicState
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
10 deletions
pdf/CHANGELOG.md
pdf/lib/src/pdf/graphic_state.dart
pdf/CHANGELOG.md
View file @
ef6944a
...
...
@@ -4,6 +4,7 @@
-
Fix documentation
-
Add Positioned.fill()
-
Improve GraphicState
## 3.1.0
...
...
pdf/lib/src/pdf/graphic_state.dart
View file @
ef6944a
...
...
@@ -20,6 +20,7 @@ import 'package:meta/meta.dart';
import
'data_types.dart'
;
import
'document.dart'
;
import
'function.dart'
;
import
'object.dart'
;
import
'smask.dart'
;
...
...
@@ -83,22 +84,40 @@ enum PdfBlendMode {
@immutable
class
PdfGraphicState
{
/// Create a new graphic state
const
PdfGraphicState
({
this
.
opacity
,
this
.
blendMode
,
this
.
softMask
});
/// The opacity to apply to this graphic state
final
double
?
opacity
;
const
PdfGraphicState
({
double
?
opacity
,
double
?
strokeOpacity
,
double
?
fillOpacity
,
this
.
blendMode
,
this
.
softMask
,
this
.
transferFunction
,
})
:
fillOpacity
=
fillOpacity
??
opacity
,
strokeOpacity
=
strokeOpacity
??
opacity
;
/// Fill opacity to apply to this graphic state
final
double
?
fillOpacity
;
/// Stroke opacity to apply to this graphic state
final
double
?
strokeOpacity
;
/// The current blend mode to be used
final
PdfBlendMode
?
blendMode
;
/// Opacity mask
final
PdfSoftMask
?
softMask
;
/// Color transfer function
final
PdfFunction
?
transferFunction
;
PdfDict
output
()
{
final
params
=
PdfDict
();
if
(
opacity
!=
null
)
{
params
[
'/CA'
]
=
PdfNum
(
opacity
!);
params
[
'/ca'
]
=
PdfNum
(
opacity
!);
if
(
strokeOpacity
!=
null
)
{
params
[
'/CA'
]
=
PdfNum
(
strokeOpacity
!);
}
if
(
fillOpacity
!=
null
)
{
params
[
'/ca'
]
=
PdfNum
(
fillOpacity
!);
}
if
(
blendMode
!=
null
)
{
...
...
@@ -111,6 +130,10 @@ class PdfGraphicState {
params
[
'/SMask'
]
=
softMask
!.
output
();
}
if
(
transferFunction
!=
null
)
{
params
[
'/TR'
]
=
transferFunction
!.
ref
();
}
return
params
;
}
...
...
@@ -119,13 +142,20 @@ class PdfGraphicState {
if
(!(
other
is
PdfGraphicState
))
{
return
false
;
}
return
other
.
opacity
==
opacity
&&
return
other
.
fillOpacity
==
fillOpacity
&&
other
.
strokeOpacity
==
strokeOpacity
&&
other
.
blendMode
==
blendMode
&&
other
.
softMask
==
softMask
;
other
.
softMask
==
softMask
&&
other
.
transferFunction
==
transferFunction
;
}
@override
int
get
hashCode
=>
opacity
.
hashCode
;
int
get
hashCode
=>
fillOpacity
.
hashCode
*
strokeOpacity
.
hashCode
*
blendMode
.
hashCode
*
softMask
.
hashCode
*
transferFunction
.
hashCode
;
}
/// Stores all the graphic states used in the document
...
...
Please
register
or
login
to post a comment