From 7b318c5156ae8b4c9a014717416ceaab7cf2aade Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 14 Mar 2024 10:23:18 +1100 Subject: Add ColourRGBA::Grey constructing method to simplify use of grey-scale colours. Use symbolic constants for colour components, fixing 'magic number' warnings. --- src/Geometry.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/Geometry.h') diff --git a/src/Geometry.h b/src/Geometry.h index a9daa5516..d02a25bbb 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -182,7 +182,7 @@ public: constexpr explicit ColourRGBA(int co_ = 0) noexcept : co(co_) { } - constexpr ColourRGBA(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha= maximumByte) noexcept : + constexpr ColourRGBA(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha=maximumByte) noexcept : ColourRGBA(red | (green << 8) | (blue << 16) | (alpha << 24)) { } @@ -194,6 +194,10 @@ public: return ColourRGBA(co_ | (maximumByte << 24)); } + static constexpr ColourRGBA Grey(unsigned int grey, unsigned int alpha=maximumByte) noexcept { + return ColourRGBA(grey, grey, grey, alpha); + } + static constexpr ColourRGBA FromIpRGB(intptr_t co_) noexcept { const int rgb = co_ & rgbMask; return ColourRGBA(rgb | (maximumByte << 24)); -- cgit v1.2.3