David PHAM-VAN

Add PdfColor.shade

@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 - Improve Internal data structure 7 - Improve Internal data structure
8 - Remove deprecated functions 8 - Remove deprecated functions
9 - Optimize file size 9 - Optimize file size
  10 +- Add PdfColor.shade
10 11
11 ## 1.5.0 12 ## 1.5.0
12 13
@@ -141,6 +141,17 @@ class PdfColor { @@ -141,6 +141,17 @@ class PdfColor {
141 return 0.2126 * R + 0.7152 * G + 0.0722 * B; 141 return 0.2126 * R + 0.7152 * G + 0.0722 * B;
142 } 142 }
143 143
  144 + /// Build a Material Color shade using the given [strength].
  145 + ///
  146 + /// To lighten a color, set the [strength] value to < .5
  147 + /// To darken a color, set the [strength] value to > .5
  148 + PdfColor shade(double strength) {
  149 + final double ds = 1.5 - strength;
  150 + final PdfColorHsl hsl = toHsl();
  151 +
  152 + return PdfColorHsl(hsl.hue, hsl.saturation, hsl.lightness * ds);
  153 + }
  154 +
144 /// Get a complementary color with hue shifted by -120° 155 /// Get a complementary color with hue shifted by -120°
145 PdfColor get complementary => toHsv().complementary; 156 PdfColor get complementary => toHsv().complementary;
146 157