Showing
2 changed files
with
67 additions
and
1 deletions
@@ -14,6 +14,7 @@ | @@ -14,6 +14,7 @@ | ||
14 | - Improve graphic operations | 14 | - Improve graphic operations |
15 | - Automatically calculate Shape() bounding box | 15 | - Automatically calculate Shape() bounding box |
16 | - Improve gradient functions | 16 | - Improve gradient functions |
17 | +- Add blend mode | ||
17 | 18 | ||
18 | ## 1.12.0 | 19 | ## 1.12.0 |
19 | 20 |
@@ -21,16 +21,74 @@ import 'package:meta/meta.dart'; | @@ -21,16 +21,74 @@ import 'package:meta/meta.dart'; | ||
21 | import 'data_types.dart'; | 21 | import 'data_types.dart'; |
22 | import 'document.dart'; | 22 | import 'document.dart'; |
23 | import 'object.dart'; | 23 | import 'object.dart'; |
24 | +enum PdfBlendMode { | ||
25 | + /// Selects the source colour, ignoring the backdrop | ||
26 | + normal, | ||
27 | + | ||
28 | + /// Multiplies the backdrop and source colour values | ||
29 | + multiply, | ||
30 | + | ||
31 | + /// Multiplies the complements of the backdrop and source colour values, | ||
32 | + /// then complements the result | ||
33 | + screen, | ||
34 | + | ||
35 | + /// Multiplies or screens the colours, depending on the backdrop colour value | ||
36 | + overlay, | ||
37 | + | ||
38 | + /// Selects the darker of the backdrop and source colours | ||
39 | + darken, | ||
40 | + | ||
41 | + /// Selects the lighter of the backdrop and source colours | ||
42 | + lighten, | ||
43 | + | ||
44 | + /// Brightens the backdrop colour to reflect the source colour. | ||
45 | + /// Painting with black produces no changes. | ||
46 | + colorDodge, | ||
47 | + | ||
48 | + /// Darkens the backdrop colour to reflect the source colour | ||
49 | + colorBurn, | ||
50 | + | ||
51 | + /// Multiplies or screens the colours, depending on the source colour value | ||
52 | + hardLight, | ||
53 | + | ||
54 | + /// Darkens or lightens the colours, depending on the source colour value | ||
55 | + softLight, | ||
56 | + | ||
57 | + /// Subtracts the darker of the two constituent colours from the lighter colour | ||
58 | + difference, | ||
59 | + | ||
60 | + /// Produces an effect similar to that of the Difference mode but lower in contrast | ||
61 | + exclusion, | ||
62 | + | ||
63 | + /// Creates a colour with the hue of the source colour and the saturation and | ||
64 | + /// luminosity of the backdrop colour | ||
65 | + hue, | ||
66 | + | ||
67 | + /// Creates a colour with the saturation of the source colour and the hue and | ||
68 | + /// luminosity of the backdrop colour | ||
69 | + saturation, | ||
70 | + | ||
71 | + /// Creates a colour with the hue and saturation of the source colour and the | ||
72 | + /// luminosity of the backdrop colour | ||
73 | + color, | ||
74 | + | ||
75 | + /// Creates a colour with the luminosity of the source colour and the hue and | ||
76 | + /// saturation of the backdrop colour | ||
77 | + luminosity, | ||
78 | +} | ||
24 | 79 | ||
25 | /// Graphic state | 80 | /// Graphic state |
26 | @immutable | 81 | @immutable |
27 | class PdfGraphicState { | 82 | class PdfGraphicState { |
28 | /// Create a new graphic state | 83 | /// Create a new graphic state |
29 | - const PdfGraphicState({this.opacity}); | 84 | + const PdfGraphicState({this.opacity, this.blendMode}); |
30 | 85 | ||
31 | /// The opacity to apply to this graphic state | 86 | /// The opacity to apply to this graphic state |
32 | final double opacity; | 87 | final double opacity; |
33 | 88 | ||
89 | + /// The current blend mode to be used | ||
90 | + final PdfBlendMode blendMode; | ||
91 | + | ||
34 | PdfDict output() { | 92 | PdfDict output() { |
35 | final params = PdfDict(); | 93 | final params = PdfDict(); |
36 | 94 | ||
@@ -39,6 +97,13 @@ class PdfGraphicState { | @@ -39,6 +97,13 @@ class PdfGraphicState { | ||
39 | params['/ca'] = PdfNum(opacity); | 97 | params['/ca'] = PdfNum(opacity); |
40 | } | 98 | } |
41 | 99 | ||
100 | + if (blendMode != null) { | ||
101 | + final bm = blendMode.toString(); | ||
102 | + print(bm); | ||
103 | + params['/BM'] = | ||
104 | + PdfName('/' + bm.substring(13, 14).toUpperCase() + bm.substring(14)); | ||
105 | + } | ||
106 | + | ||
42 | return params; | 107 | return params; |
43 | } | 108 | } |
44 | 109 |
-
Please register or login to post a comment