OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_COLOR_UTILS_H_ | 5 #ifndef UI_GFX_COLOR_UTILS_H_ |
6 #define UI_GFX_COLOR_UTILS_H_ | 6 #define UI_GFX_COLOR_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
10 #include "ui/gfx/gfx_export.h" | 10 #include "ui/gfx/gfx_export.h" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 GFX_EXPORT unsigned char GetLuminanceForColor(SkColor color); | 23 GFX_EXPORT unsigned char GetLuminanceForColor(SkColor color); |
24 | 24 |
25 // Calculated according to http://www.w3.org/TR/WCAG20/#relativeluminancedef | 25 // Calculated according to http://www.w3.org/TR/WCAG20/#relativeluminancedef |
26 GFX_EXPORT double RelativeLuminance(SkColor color); | 26 GFX_EXPORT double RelativeLuminance(SkColor color); |
27 | 27 |
28 // Note: these transformations assume sRGB as the source color space | 28 // Note: these transformations assume sRGB as the source color space |
29 GFX_EXPORT void SkColorToHSL(SkColor c, HSL* hsl); | 29 GFX_EXPORT void SkColorToHSL(SkColor c, HSL* hsl); |
30 GFX_EXPORT SkColor HSLToSkColor(const HSL& hsl, SkAlpha alpha); | 30 GFX_EXPORT SkColor HSLToSkColor(const HSL& hsl, SkAlpha alpha); |
31 | 31 |
32 // Determines whether the given |hsl| falls within the given range for each | |
33 // component. | |
34 // | |
35 // Any components of |lower_bound| or |upper_bound| that are -1 will be | |
36 // ignored. | |
Matt Giuca
2014/05/22 05:03:52
This could be construed as "the component will be
calamity
2014/05/22 07:36:36
Done.
| |
37 // | |
38 // For hue, the lower bound should be in the range [0, 1] and the upper bound | |
39 // should be in the range [(lower bound), (lower bound + 1)]. | |
40 // For saturation and value, bounds should be specified in the range [0, 1], | |
41 // with the lower bound less than the upper bound. | |
42 GFX_EXPORT bool IsWithinHSLRange(const HSL& hsl, | |
43 const HSL& lower_bound, | |
44 const HSL& upper_bound); | |
45 | |
32 // HSL-Shift an SkColor. The shift values are in the range of 0-1, with the | 46 // HSL-Shift an SkColor. The shift values are in the range of 0-1, with the |
33 // option to specify -1 for 'no change'. The shift values are defined as: | 47 // option to specify -1 for 'no change'. The shift values are defined as: |
34 // hsl_shift[0] (hue): The absolute hue value - 0 and 1 map | 48 // hsl_shift[0] (hue): The absolute hue value - 0 and 1 map |
35 // to 0 and 360 on the hue color wheel (red). | 49 // to 0 and 360 on the hue color wheel (red). |
36 // hsl_shift[1] (saturation): A saturation shift, with the | 50 // hsl_shift[1] (saturation): A saturation shift, with the |
37 // following key values: | 51 // following key values: |
38 // 0 = remove all color. | 52 // 0 = remove all color. |
39 // 0.5 = leave unchanged. | 53 // 0.5 = leave unchanged. |
40 // 1 = fully saturate the image. | 54 // 1 = fully saturate the image. |
41 // hsl_shift[2] (lightness): A lightness shift, with the | 55 // hsl_shift[2] (lightness): A lightness shift, with the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 | 88 |
75 // Invert a color. | 89 // Invert a color. |
76 GFX_EXPORT SkColor InvertColor(SkColor color); | 90 GFX_EXPORT SkColor InvertColor(SkColor color); |
77 | 91 |
78 // Gets a Windows system color as a SkColor | 92 // Gets a Windows system color as a SkColor |
79 GFX_EXPORT SkColor GetSysSkColor(int which); | 93 GFX_EXPORT SkColor GetSysSkColor(int which); |
80 | 94 |
81 } // namespace color_utils | 95 } // namespace color_utils |
82 | 96 |
83 #endif // UI_GFX_COLOR_UTILS_H_ | 97 #endif // UI_GFX_COLOR_UTILS_H_ |
OLD | NEW |