#if HAVE_CPP_CONSTEVAL
consteval #else
constexpr #endif
Color(const sal_uInt32 nColor)
: mValue(nColor)
{
assert(nColor <= 0xffffff && "don't pass transparency to this constructor, use the Color(ColorTransparencyTag,...) or Color(ColorAlphaTag,...) constructor to make it explicit");
}
/** Is the color transparent?
*/ bool IsTransparent() const
{ return GetAlpha() != 255;
}
/** Is the color fully transparent i.e. 100% transparency ?
*/ bool IsFullyTransparent() const
{ return GetAlpha() == 0;
}
/** Sets the red value. *@paramnRed
*/ void SetRed(sal_uInt8 nRed)
{
R = nRed;
}
/** Sets the green value. *@paramnGreen
*/ void SetGreen(sal_uInt8 nGreen)
{
G = nGreen;
}
/** Sets the blue value. *@paramnBlue
*/ void SetBlue(sal_uInt8 nBlue)
{
B = nBlue;
}
/** Sets the alpha value. *@paramnAlpha
*/ void SetAlpha(sal_uInt8 nAlpha)
{
T = 255 - nAlpha;
}
/** Returns the same color but ignoring the transparency value. *@returnRGBversion
*/
Color GetRGBColor() const
{ return { GetRed(), GetGreen(), GetBlue() };
}
/* Comparison and operators */
/** Check if the color RGB value is equal than rColor. *@paramrColor *@returnisequal
*/ bool IsRGBEqual( const Color& rColor ) const
{ return ( mValue & 0x00FFFFFF ) == ( rColor.mValue & 0x00FFFFFF );
}
/** Check if the color value is lower than aCompareColor. *@paramaCompareColor *@returnislower
*/ booloperator<(const Color& aCompareColor) const
{ return mValue < aCompareColor.mValue;
}
/** Check if the color value is greater than aCompareColor. *@paramaCompareColor *@returnisgreater
*/ booloperator>(const Color& aCompareColor) const
{ return mValue > aCompareColor.mValue;
}
/** Check if the color value is equal than rColor. *@paramrColor *@returnisequal
*/ booloperator==(const Color& rColor) const
{ return mValue == rColor.mValue;
}
/** Color space conversion tools *Therangeforh/s/bis: *-Hue:0-360degree *-Saturation:0-100% *-Brightness:0-100% *@paramnHue *@paramnSaturation *@paramnBrightness *@returnrgbcolor
*/ static Color HSBtoRGB(sal_uInt16 nHue, sal_uInt16 nSaturation, sal_uInt16 nBrightness);
/** Converts a string into a color. Supports: *#RRGGBB *#rrggbb *#RGB *#rgb *RRGGBB *rrggbb *RGB *rgb *IffailsreturnsColor().
*/ static Color STRtoRGB(std::u16string_view colorname);
/** Color space conversion tools *@paramnHue *@paramnSaturation *@paramnBrightness
*/ void RGBtoHSB(sal_uInt16& nHue, sal_uInt16& nSaturation, sal_uInt16& nBrightness) const;
/* Return color as RGB hex string: rrggbb *forexample"00ff00"forgreencolor *@returnhexstring
*/
OUString AsRGBHexString() const;
/* Return color as RGB hex string: RRGGBB *forexample"00FF00"forgreencolor *@returnhexstring
*/
OUString AsRGBHEXString() const;
/* get ::basegfx::BColor from this color *@returnbasegfxcolor
*/
basegfx::BColor getBColor() const
{
basegfx::BColor aColor(GetRed() / 255.0, GetGreen() / 255.0, GetBlue() / 255.0); if (mValue == Color(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF).mValue)
aColor.setAutomatic(true); return aColor;
}
};
// to reduce the noise when moving these into and out of Any inlinebooloperator >>=( const css::uno::Any & rAny, Color & value )
{
sal_Int32 nTmp = {}; // spurious -Werror=maybe-uninitialized if (!(rAny >>= nTmp)) returnfalse;
value = Color(ColorTransparency, nTmp); returntrue;
}
inlinevoidoperator <<=( css::uno::Any & rAny, Color value )
{
rAny <<= sal_Int32(value);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.