diff options
Diffstat (limited to 'skia/ext/skia_utils.h')
-rw-r--r-- | skia/ext/skia_utils.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/skia/ext/skia_utils.h b/skia/ext/skia_utils.h index 98fa1b0..0f61b18 100644 --- a/skia/ext/skia_utils.h +++ b/skia/ext/skia_utils.h @@ -10,6 +10,12 @@ namespace skia { +struct HSL { + double h; + double s; + double l; +}; + // Creates a vertical gradient shader. The caller owns the shader. // Example usage to avoid leaks: // paint.setShader(gfx::CreateGradientShader(0, 10, red, blue))->safeUnref(); @@ -22,10 +28,27 @@ SkShader* CreateGradientShader(int start_point, SkColor end_color); // Convert a premultiplied SkColor to a HSL value. -void SkColorToHSL(SkPMColor c, float hsl[3]); +void SkColorToHSL(SkPMColor c, HSL& hsl); // Convert a HSL color to a premultiplied SkColor. -SkPMColor HSLToSKColor(U8CPU alpha, float hsl[3]); +SkPMColor HSLToSKColor(U8CPU alpha, HSL hsl); + +// Shift an HSL value. The shift values are in the range of 0-1, +// with the option to specify -1 for 'no change'. The shift values are +// defined as: +// hsl_shift[0] (hue): The absolute hue value - 0 and 1 map +// to 0 and 360 on the hue color wheel (red). +// hsl_shift[1] (saturation): A saturation shift, with the +// following key values: +// 0 = remove all color. +// 0.5 = leave unchanged. +// 1 = fully saturate the image. +// hsl_shift[2] (lightness): A lightness shift, with the +// following key values: +// 0 = remove all lightness (make all pixels black). +// 0.5 = leave unchanged. +// 1 = full lightness (make all pixels white). +SkColor HSLShift(skia::HSL hsl, skia::HSL shift); } // namespace skia |