michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* functions that manipulate colors */ michael@0: michael@0: #ifndef __nsCSSColorUtils_h michael@0: #define __nsCSSColorUtils_h michael@0: michael@0: #include "nsColor.h" michael@0: michael@0: // "Sufficient contrast" is determined by michael@0: // "Techniques For Accessibility Evalution And Repair Tools". michael@0: // See http://www.w3.org/TR/AERT#color-contrast michael@0: #define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000 michael@0: #define NS_LUMINOSITY_DIFFERENCE(a, b) \ michael@0: int32_t(mozilla::Abs(NS_GetLuminosity(a) - NS_GetLuminosity(b))) michael@0: michael@0: // To determine colors based on the background brightness and border color michael@0: void NS_GetSpecial3DColors(nscolor aResult[2], michael@0: nscolor aBackgroundColor, michael@0: nscolor aBorderColor); michael@0: michael@0: // Determins brightness for a specific color michael@0: int NS_GetBrightness(uint8_t aRed, uint8_t aGreen, uint8_t aBlue); michael@0: michael@0: // Get Luminosity of a specific color. That is same as Y of YIQ color space. michael@0: // The range of return value is 0 to 255000. michael@0: int32_t NS_GetLuminosity(nscolor aColor); michael@0: michael@0: // function to convert from RGBA color space to HSVA color space michael@0: void NS_RGB2HSV(nscolor aColor, uint16_t &aHue, uint16_t &aSat, michael@0: uint16_t &aValue, uint8_t &aAlpha); michael@0: michael@0: // function to convert from HSVA color space to RGBA color space michael@0: void NS_HSV2RGB(nscolor &aColor, uint16_t aHue, uint16_t aSat, uint16_t aValue, michael@0: uint8_t aAlpha); michael@0: michael@0: #endif