43 const double fLuminance(aSourceColor.luminance());
45 return ::basegfx::BColor(fLuminance, fLuminance, fLuminance);
64 return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue());
83 const double fAlpha(1.0 - ((aSourceColor.getRed() * 0.2125) + (aSourceColor.getGreen() * 0.7154) + (aSourceColor.getBlue() * 0.0721)));
85 return ::basegfx::BColor(fAlpha, fAlpha, fAlpha);
90 return "luminance_to_alpha";
142 return "interpolate";
166 const double aRed =
maVector[0] * aSourceColor.getRed()
167 +
maVector[1] * aSourceColor.getGreen()
168 +
maVector[2] * aSourceColor.getBlue()
171 const double aGreen =
maVector[5] * aSourceColor.getRed()
172 +
maVector[6] * aSourceColor.getGreen()
173 +
maVector[7] * aSourceColor.getBlue()
176 const double aBlue =
maVector[10] * aSourceColor.getRed()
177 +
maVector[11] * aSourceColor.getGreen()
178 +
maVector[12] * aSourceColor.getBlue()
189 return ::basegfx::BColor(
190 std::clamp(aRed, 0.0, 1.0),
191 std::clamp(aGreen, 0.0, 1.0),
192 std::clamp(aBlue, 0.0, 1.0));
232 aColorMatrix.
set(0, 0, aSourceColor.getRed());
233 aColorMatrix.
set(1, 0, aSourceColor.getGreen());
234 aColorMatrix.
set(2, 0, aSourceColor.getBlue());
237 return ::basegfx::BColor(aColorMatrix.
get(0, 0), aColorMatrix.
get(1, 0), aColorMatrix.
get(2, 0));
247 const double fCos = cos(fRad);
248 const double fSin = sin(fRad);
280 aColorMatrix.
set(0, 0, aSourceColor.getRed());
281 aColorMatrix.
set(1, 0, aSourceColor.getGreen());
282 aColorMatrix.
set(2, 0, aSourceColor.getBlue());
285 return ::basegfx::BColor(
286 std::clamp(aColorMatrix.
get(0, 0), 0.0, 1.0),
287 std::clamp(aColorMatrix.
get(1, 0), 0.0, 1.0),
288 std::clamp(aColorMatrix.
get(2, 0), 0.0, 1.0));
314 const double fLuminance(aSourceColor.luminance());
318 return ::basegfx::BColor::getEmptyBColor();
322 return ::basegfx::BColor(1.0, 1.0, 1.0);
328 return "black_and_white";
331 BColorModifier_gamma::BColorModifier_gamma(
double fValue)
342 BColorModifier_gamma::~BColorModifier_gamma()
346 bool BColorModifier_gamma::operator==(
const BColorModifier& rCompare)
const
348 const BColorModifier_gamma* pCompare =
dynamic_cast< const BColorModifier_gamma*
>(&rCompare);
356 return mfValue == pCompare->mfValue;
359 ::basegfx::BColor BColorModifier_gamma::getModifiedColor(const ::basegfx::BColor& aSourceColor)
const
364 pow(aSourceColor.getRed(), mfInvValue),
365 pow(aSourceColor.getGreen(), mfInvValue),
366 pow(aSourceColor.getBlue(), mfInvValue));
377 OUString BColorModifier_gamma::getModifierName()
const
382 BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(
double fRed,
double fGreen,
double fBlue,
double fLuminance,
double fContrast)
383 : mfRed(
std::clamp(fRed, -1.0, 1.0)),
384 mfGreen(
std::clamp(fGreen, -1.0, 1.0)),
385 mfBlue(
std::clamp(fBlue, -1.0, 1.0)),
386 mfLuminance(
std::clamp(fLuminance, -1.0, 1.0)),
387 mfContrast(
std::clamp(fContrast, -1.0, 1.0)),
402 if(mfContrast >= 0.0)
404 mfContrastOff = 128.0 / (128.0 - (mfContrast * 127.0));
408 mfContrastOff = ( 128.0 + (mfContrast * 127.0)) / 128.0;
412 const double fPreparedContrastOff((128.0 - mfContrastOff * 128.0) / 255.0);
413 const double fCombinedOffset(mfLuminance + fPreparedContrastOff);
416 mfRedOff = mfRed + fCombinedOffset;
417 mfGreenOff = mfGreen + fCombinedOffset;
418 mfBlueOff = mfBlue + fCombinedOffset;
423 BColorModifier_RGBLuminanceContrast::~BColorModifier_RGBLuminanceContrast()
427 bool BColorModifier_RGBLuminanceContrast::operator==(
const BColorModifier& rCompare)
const
429 const BColorModifier_RGBLuminanceContrast* pCompare =
dynamic_cast< const BColorModifier_RGBLuminanceContrast*
>(&rCompare);
437 return mfRed == pCompare->mfRed
438 && mfGreen == pCompare->mfGreen
439 && mfBlue == pCompare->mfBlue
440 && mfLuminance == pCompare->mfLuminance
441 && mfContrast == pCompare->mfContrast;
444 ::basegfx::BColor BColorModifier_RGBLuminanceContrast::getModifiedColor(const ::basegfx::BColor& aSourceColor)
const
449 std::clamp(aSourceColor.getRed() * mfContrastOff + mfRedOff, 0.0, 1.0),
450 std::clamp(aSourceColor.getGreen() * mfContrastOff + mfGreenOff, 0.0, 1.0),
451 std::clamp(aSourceColor.getBlue() * mfContrastOff + mfBlueOff, 0.0, 1.0));
459 OUString BColorModifier_RGBLuminanceContrast::getModifierName()
const
461 return "RGBLuminanceContrast";
465 : mfRandomPart(fRandomPart)
507 aSourceColor.getRed() * fMulA +
509 aSourceColor.getGreen() * fMulA +
511 aSourceColor.getBlue() * fMulA +
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
double get(sal_uInt16 nRow, sal_uInt16 nColumn) const
::std::vector< BColorModifierSharedPtr > maBColorModifiers
::basegfx::BColor getModifiedColor(const ::basegfx::BColor &rSource) const
convert color to black and white
virtual ~BColorModifier_black_and_white() override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual ~BColorModifier_gray() override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
Apply hueRotate This derivation is used for the svg importer and does exactly what SVG defines for th...
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
basegfx::B3DHomMatrix maHueMatrix
BColorModifier_hueRotate(double fRad)
virtual ~BColorModifier_hueRotate() override
virtual ~BColorModifier_interpolate() override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
::basegfx::BColor maBColor
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual ~BColorModifier_invert() override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
convert to alpha based on luminance
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual ~BColorModifier_luminance_to_alpha() override
Apply matrix This derivation is used for the svg importer and does exactly what SVG defines for this ...
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual ~BColorModifier_matrix() override
std::vector< double > maVector
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual SAL_DLLPRIVATE OUString getModifierName() const override
BColorModifier_randomize(double fRandomPart=0.1)
virtual ~BColorModifier_randomize() override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
const ::basegfx::BColor & getBColor() const
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
::basegfx::BColor maBColor
virtual ~BColorModifier_replace() override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
Apply saturation This derivation is used for the svg importer and does exactly what SVG defines for t...
BColorModifier_saturate(double fValue)
basegfx::B3DHomMatrix maSatMatrix
virtual SAL_DLLPRIVATE OUString getModifierName() const override
virtual SAL_DLLPRIVATE ::basegfx::BColor getModifiedColor(const ::basegfx::BColor &aSourceColor) const override
virtual SAL_DLLPRIVATE bool operator==(const BColorModifier &rCompare) const override
virtual ~BColorModifier_saturate() override
base class to define color modifications
virtual ~BColorModifier()
Base Color class with three double values.
B2DTuple interpolate(const B2DTuple &rOld1, const B2DTuple &rOld2, double t)
double uniform_real_distribution(double a=0.0, double b=1.0)