aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Geometry.cxx24
-rw-r--r--src/Geometry.h20
2 files changed, 26 insertions, 18 deletions
diff --git a/src/Geometry.cxx b/src/Geometry.cxx
index afdc5d161..97e99d431 100644
--- a/src/Geometry.cxx
+++ b/src/Geometry.cxx
@@ -12,6 +12,14 @@
#include "Geometry.h"
+namespace {
+
+constexpr unsigned int Mixed(unsigned char a, unsigned char b, double proportion) noexcept {
+ return static_cast<unsigned int>(a + proportion * (b - a));
+}
+
+}
+
namespace Scintilla::Internal {
PRectangle Clamp(PRectangle rc, Edge edge, XYPOSITION position) noexcept {
@@ -95,4 +103,20 @@ PRectangle PixelAlignOutside(const PRectangle &rc, int pixelDivisions) noexcept
std::floor(rc.bottom * pixelDivisions) / pixelDivisions);
}
+ColourRGBA ColourRGBA::MixedWith(ColourRGBA other) const noexcept {
+ const unsigned int red = (GetRed() + other.GetRed()) / 2;
+ const unsigned int green = (GetGreen() + other.GetGreen()) / 2;
+ const unsigned int blue = (GetBlue() + other.GetBlue()) / 2;
+ const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2;
+ return ColourRGBA(red, green, blue, alpha);
+}
+
+ColourRGBA ColourRGBA::MixedWith(ColourRGBA other, double proportion) const noexcept {
+ return ColourRGBA(
+ Mixed(GetRed(), other.GetRed(), proportion),
+ Mixed(GetGreen(), other.GetGreen(), proportion),
+ Mixed(GetBlue(), other.GetBlue(), proportion),
+ Mixed(GetAlpha(), other.GetAlpha(), proportion));
+}
+
}
diff --git a/src/Geometry.h b/src/Geometry.h
index 28241c5a9..5a9b3e291 100644
--- a/src/Geometry.h
+++ b/src/Geometry.h
@@ -161,9 +161,6 @@ PRectangle PixelAlignOutside(const PRectangle &rc, int pixelDivisions) noexcept;
constexpr const float componentMaximum = 255.0f;
class ColourRGBA {
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 ColourRGBA(int co_ = 0) noexcept : co(co_) {
}
@@ -236,21 +233,8 @@ public:
return GetAlpha() == 0xff;
}
- constexpr ColourRGBA MixedWith(ColourRGBA other) const noexcept {
- const unsigned int red = (GetRed() + other.GetRed()) / 2;
- const unsigned int green = (GetGreen() + other.GetGreen()) / 2;
- const unsigned int blue = (GetBlue() + other.GetBlue()) / 2;
- const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2;
- return ColourRGBA(red, green, blue, alpha);
- }
-
- constexpr ColourRGBA MixedWith(ColourRGBA other, double proportion) const noexcept {
- return ColourRGBA(
- Mixed(GetRed(), other.GetRed(), proportion),
- Mixed(GetGreen(), other.GetGreen(), proportion),
- Mixed(GetBlue(), other.GetBlue(), proportion),
- Mixed(GetAlpha(), other.GetAlpha(), proportion));
- }
+ ColourRGBA MixedWith(ColourRGBA other) const noexcept;
+ ColourRGBA MixedWith(ColourRGBA other, double proportion) const noexcept;
};
/**