Showing
2 changed files
with
12 additions
and
0 deletions
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | - Add PdfOutline.toString() | 8 | - Add PdfOutline.toString() |
| 9 | - Add equality operator to PdfPageFormat | 9 | - Add equality operator to PdfPageFormat |
| 10 | - Improve TextStyle decoration merging | 10 | - Improve TextStyle decoration merging |
| 11 | +- Add PdfColor.flatten | ||
| 11 | 12 | ||
| 12 | ## 3.3.0 | 13 | ## 3.3.0 |
| 13 | 14 |
| @@ -228,6 +228,17 @@ class PdfColor { | @@ -228,6 +228,17 @@ class PdfColor { | ||
| 228 | /// Returns a list of analagous colors | 228 | /// Returns a list of analagous colors |
| 229 | List<PdfColor> get analagous => toHsv().analagous; | 229 | List<PdfColor> get analagous => toHsv().analagous; |
| 230 | 230 | ||
| 231 | + /// Apply the color transparency by updating the color values according to a | ||
| 232 | + /// background color. | ||
| 233 | + PdfColor flatten({PdfColor background = const PdfColor(1, 1, 1)}) { | ||
| 234 | + return PdfColor( | ||
| 235 | + alpha * red + (1 - alpha) * background.red, | ||
| 236 | + alpha * green + (1 - alpha) * background.green, | ||
| 237 | + alpha * blue + (1 - alpha) * background.blue, | ||
| 238 | + background.alpha, | ||
| 239 | + ); | ||
| 240 | + } | ||
| 241 | + | ||
| 231 | @override | 242 | @override |
| 232 | String toString() => '$runtimeType($red, $green, $blue, $alpha)'; | 243 | String toString() => '$runtimeType($red, $green, $blue, $alpha)'; |
| 233 | 244 |
-
Please register or login to post a comment