Showing
2 changed files
with
12 additions
and
0 deletions
@@ -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 |
-
Please register or login to post a comment