From d4a5d7d6955982496ba523a439fc98276a28e2d8 Mon Sep 17 00:00:00 2001 From: Neil Date: Wed, 15 Sep 2021 09:36:45 +1000 Subject: Move colour mixing implementations into implementation file. Avoids some warnings but drops constexpr. Use MixedWith in PlatWin for GDI instead of local implementation. Add unit tests for Geometry. --- win32/PlatWin.cxx | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'win32') diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 3e966b4d3..c4f08b798 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -865,18 +865,6 @@ void DIBSection::SetSymmetric(LONG x, LONG y, DWORD value) noexcept { SetPixel(xSymmetric, ySymmetric, value); } -constexpr unsigned int Proportional(unsigned char a, unsigned char b, XYPOSITION t) noexcept { - return static_cast(a + t * (b - a)); -} - -ColourRGBA Proportional(ColourRGBA a, ColourRGBA b, XYPOSITION t) noexcept { - return ColourRGBA( - Proportional(a.GetRed(), b.GetRed(), t), - Proportional(a.GetGreen(), b.GetGreen(), t), - Proportional(a.GetBlue(), b.GetBlue(), t), - Proportional(a.GetAlpha(), b.GetAlpha(), t)); -} - ColourRGBA GradientValue(const std::vector &stops, XYPOSITION proportion) noexcept { for (size_t stop = 0; stop < stops.size() - 1; stop++) { // Loop through each pair of stops @@ -885,7 +873,7 @@ ColourRGBA GradientValue(const std::vector &stops, XYPOSITION propor if ((proportion >= positionStart) && (proportion <= positionEnd)) { const XYPOSITION proportionInPair = (proportion - positionStart) / (positionEnd - positionStart); - return Proportional(stops[stop].colour, stops[stop + 1].colour, proportionInPair); + return stops[stop].colour.MixedWith(stops[stop + 1].colour, proportionInPair); } } // Loop should always find a value -- cgit v1.2.3