aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Geometry.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-05-14 13:33:56 +1000
committerNeil <nyamatongwe@gmail.com>2021-05-14 13:33:56 +1000
commit06bf4367ac6d71d162389619b8dd574bce1ba320 (patch)
tree842fe429440d87d1a9b5366dcc5535f732c52d93 /src/Geometry.h
parent91a0a5c9be59308be001bbc89c0aead0f3602494 (diff)
downloadscintilla-mirror-06bf4367ac6d71d162389619b8dd574bce1ba320.tar.gz
Add method to mix colours in a proportion.
Diffstat (limited to 'src/Geometry.h')
-rw-r--r--src/Geometry.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Geometry.h b/src/Geometry.h
index a6e49ad5b..e28cf861e 100644
--- a/src/Geometry.h
+++ b/src/Geometry.h
@@ -167,6 +167,9 @@ PRectangle PixelAlignOutside(const PRectangle &rc, int pixelDivisions) noexcept;
constexpr const float componentMaximum = 255.0f;
class ColourAlpha {
int co;
+ constexpr static unsigned int Mixed(unsigned char a, unsigned char b, double proportion) noexcept {
+ return static_cast<unsigned int>(a + proportion * (b - a));
+ }
public:
constexpr explicit ColourAlpha(int co_ = 0) noexcept : co(co_) {
}
@@ -242,6 +245,14 @@ public:
const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2;
return ColourAlpha(red, green, blue, alpha);
}
+
+ constexpr ColourAlpha MixedWith(ColourAlpha other, double proportion) const noexcept {
+ return ColourAlpha(
+ Mixed(GetRed(), other.GetRed(), proportion),
+ Mixed(GetGreen(), other.GetGreen(), proportion),
+ Mixed(GetBlue(), other.GetBlue(), proportion),
+ Mixed(GetAlpha(), other.GetAlpha(), proportion));
+ }
};
/**