diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-14 12:39:06 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-06-14 21:08:17 +0200 |
commit | 41bf4139cab36984cff514bfdd6b1b13576746a3 (patch) | |
tree | f976deb977ad2b7bc372b1193fde8984a3842bd8 /basegfx | |
parent | b6474249caa697513affdbcb02c7a69fda8203be (diff) |
tdf#155735: Add support for saturate type
Add getModifierName to BColorModifier class so when
can assert which modifier is being used
Change-Id: I2bc2a36470a449df4dc84a8440f232149c1f8278
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153048
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'basegfx')
-rw-r--r-- | basegfx/source/color/bcolormodifier.cxx | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/basegfx/source/color/bcolormodifier.cxx b/basegfx/source/color/bcolormodifier.cxx index f27ffcc9aaf0..2067257015b4 100644 --- a/basegfx/source/color/bcolormodifier.cxx +++ b/basegfx/source/color/bcolormodifier.cxx @@ -45,6 +45,11 @@ namespace basegfx return ::basegfx::BColor(fLuminance, fLuminance, fLuminance); } + OUString BColorModifier_gray::getModifierName() const + { + return "gray"; + } + BColorModifier_invert::~BColorModifier_invert() { } @@ -59,6 +64,11 @@ namespace basegfx return ::basegfx::BColor(1.0 - aSourceColor.getRed(), 1.0 - aSourceColor.getGreen(), 1.0 - aSourceColor.getBlue()); } + OUString BColorModifier_invert::getModifierName() const + { + return "invert"; + } + BColorModifier_luminance_to_alpha::~BColorModifier_luminance_to_alpha() { } @@ -75,6 +85,11 @@ namespace basegfx return ::basegfx::BColor(fAlpha, fAlpha, fAlpha); } + OUString BColorModifier_luminance_to_alpha::getModifierName() const + { + return "luminance_to_alpha"; + } + BColorModifier_replace::~BColorModifier_replace() { } @@ -96,6 +111,11 @@ namespace basegfx return maBColor; } + OUString BColorModifier_replace::getModifierName() const + { + return "replace"; + } + BColorModifier_interpolate::~BColorModifier_interpolate() { } @@ -117,6 +137,40 @@ namespace basegfx return interpolate(maBColor, aSourceColor, mfValue); } + OUString BColorModifier_interpolate::getModifierName() const + { + return "interpolate"; + } + + BColorModifier_saturate::~BColorModifier_saturate() + { + } + + bool BColorModifier_saturate::operator==(const BColorModifier& rCompare) const + { + const BColorModifier_saturate* pCompare = dynamic_cast< const BColorModifier_saturate* >(&rCompare); + + if(!pCompare) + { + return false; + } + + return mfValue == pCompare->mfValue; + } + + ::basegfx::BColor BColorModifier_saturate::getModifiedColor(const ::basegfx::BColor& aSourceColor) const + { + return basegfx::BColor( + (0.213 + 0.787 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 * mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * aSourceColor.getBlue(), + (0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 + 0.285 * mfValue) * aSourceColor.getGreen() + (0.072 - 0.072 * mfValue) * aSourceColor.getBlue(), + (0.213 - 0.213 * mfValue) * aSourceColor.getRed() + (0.715 - 0.715 * mfValue) * aSourceColor.getGreen() + (0.072 + 0.928 * mfValue) * aSourceColor.getBlue()); + } + + OUString BColorModifier_saturate::getModifierName() const + { + return "saturate"; + } + BColorModifier_black_and_white::~BColorModifier_black_and_white() { } @@ -147,6 +201,11 @@ namespace basegfx } } + OUString BColorModifier_black_and_white::getModifierName() const + { + return "black_and_white"; + } + BColorModifier_gamma::BColorModifier_gamma(double fValue) : mfValue(fValue), mfInvValue(fValue), @@ -193,6 +252,11 @@ namespace basegfx } } + OUString BColorModifier_gamma::getModifierName() const + { + return "gamma"; + } + BColorModifier_RGBLuminanceContrast::BColorModifier_RGBLuminanceContrast(double fRed, double fGreen, double fBlue, double fLuminance, double fContrast) : mfRed(std::clamp(fRed, -1.0, 1.0)), mfGreen(std::clamp(fGreen, -1.0, 1.0)), @@ -270,6 +334,11 @@ namespace basegfx } } + OUString BColorModifier_RGBLuminanceContrast::getModifierName() const + { + return "RGBLuminanceContrast"; + } + BColorModifier_randomize::BColorModifier_randomize(double fRandomPart) : mfRandomPart(fRandomPart) { @@ -321,6 +390,11 @@ namespace basegfx comphelper::rng::uniform_real_distribution(0.0, nextafter(mfRandomPart, DBL_MAX))); } + OUString BColorModifier_randomize::getModifierName() const + { + return "randomize"; + } + ::basegfx::BColor BColorModifierStack::getModifiedColor(const ::basegfx::BColor& rSource) const { if(maBColorModifiers.empty()) |