Showing
2 changed files
with
15 additions
and
5 deletions
@@ -6,6 +6,7 @@ | @@ -6,6 +6,7 @@ | ||
6 | - Fix GridView when empty | 6 | - Fix GridView when empty |
7 | - Reorder MultiPage paint operations | 7 | - Reorder MultiPage paint operations |
8 | - Fix Bullet widget styling | 8 | - Fix Bullet widget styling |
9 | +- Fix HSV and HSL Color constructors | ||
9 | 10 | ||
10 | ## 1.4.1 | 11 | ## 1.4.1 |
11 | 12 |
@@ -247,8 +247,8 @@ class PdfColorHsv extends PdfColor { | @@ -247,8 +247,8 @@ class PdfColorHsv extends PdfColor { | ||
247 | blue = secondary; | 247 | blue = secondary; |
248 | } | 248 | } |
249 | 249 | ||
250 | - return PdfColorHsv._(hue, saturation, value, red + match, green + match, | ||
251 | - blue + match, alpha); | 250 | + return PdfColorHsv._(hue, saturation, value, (red + match).clamp(0.0, 1.0), |
251 | + (green + match).clamp(0.0, 1.0), (blue + match).clamp(0.0, 1.0), alpha); | ||
252 | } | 252 | } |
253 | 253 | ||
254 | const PdfColorHsv._(this.hue, this.saturation, this.value, double red, | 254 | const PdfColorHsv._(this.hue, this.saturation, this.value, double red, |
@@ -375,13 +375,22 @@ class PdfColorHsl extends PdfColor { | @@ -375,13 +375,22 @@ class PdfColorHsl extends PdfColor { | ||
375 | green = 0.0; | 375 | green = 0.0; |
376 | blue = secondary; | 376 | blue = secondary; |
377 | } | 377 | } |
378 | - return PdfColorHsl._(hue, saturation, lightness, alpha, red + match, | ||
379 | - green + match, blue + match); | 378 | + return PdfColorHsl._( |
379 | + hue, | ||
380 | + saturation, | ||
381 | + lightness, | ||
382 | + alpha, | ||
383 | + (red + match).clamp(0.0, 1.0), | ||
384 | + (green + match).clamp(0.0, 1.0), | ||
385 | + (blue + match).clamp(0.0, 1.0)); | ||
380 | } | 386 | } |
381 | 387 | ||
382 | const PdfColorHsl._(this.hue, this.saturation, this.lightness, double alpha, | 388 | const PdfColorHsl._(this.hue, this.saturation, this.lightness, double alpha, |
383 | double red, double green, double blue) | 389 | double red, double green, double blue) |
384 | - : super(red, green, blue, alpha); | 390 | + : assert(hue >= 0 && hue < 360), |
391 | + assert(saturation >= 0 && saturation <= 1), | ||
392 | + assert(lightness >= 0 && lightness <= 1), | ||
393 | + super(red, green, blue, alpha); | ||
385 | 394 | ||
386 | factory PdfColorHsl.fromRgb(double red, double green, double blue, | 395 | factory PdfColorHsl.fromRgb(double red, double green, double blue, |
387 | [double alpha = 1.0]) { | 396 | [double alpha = 1.0]) { |
-
Please register or login to post a comment