From 182c8f8357739f905bbd721006480502435b6b43 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 27 Nov 2022 12:04:31 -0800 Subject: Update brace style to match rest of my projects --- app/source/Cplt/Utils/Color.hpp | 66 ++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 44 deletions(-) (limited to 'app/source/Cplt/Utils/Color.hpp') diff --git a/app/source/Cplt/Utils/Color.hpp b/app/source/Cplt/Utils/Color.hpp index 15fe6a1..6d56951 100644 --- a/app/source/Cplt/Utils/Color.hpp +++ b/app/source/Cplt/Utils/Color.hpp @@ -9,8 +9,7 @@ #include #include -class RgbaColor -{ +class RgbaColor { public: uint8_t r; uint8_t g; @@ -22,36 +21,31 @@ public: : r{ 255 } , g{ 255 } , b{ 255 } - , a{ 255 } - { + , a{ 255 } { } constexpr RgbaColor(float r, float g, float b, float a = 1.0f) noexcept : r{ static_cast(r * 255.0f) } , g{ static_cast(g * 255.0f) } , b{ static_cast(b * 255.0f) } - , a{ static_cast(a * 255.0f) } - { + , a{ static_cast(a * 255.0f) } { } constexpr RgbaColor(int r, int g, int b, int a = 255) noexcept : r{ static_cast(r & 0xFF) } , g{ static_cast(g & 0xFF) } , b{ static_cast(b & 0xFF) } - , a{ static_cast(a & 0xFF) } - { + , a{ static_cast(a & 0xFF) } { } constexpr RgbaColor(uint32_t rgba) noexcept : r{ static_cast((rgba >> 0) & 0xFF) } , g{ static_cast((rgba >> 8) & 0xFF) } , b{ static_cast((rgba >> 16) & 0xFF) } - , a{ static_cast((rgba >> 24) & 0xFF) } - { + , a{ static_cast((rgba >> 24) & 0xFF) } { } - constexpr uint32_t GetScalar() const noexcept - { + constexpr uint32_t GetScalar() const noexcept { uint32_t res = 0; res |= r << 24; res |= g << 16; @@ -60,41 +54,34 @@ public: return res; } - constexpr void SetScalar(uint32_t scalar) noexcept - { + constexpr void SetScalar(uint32_t scalar) noexcept { r = (scalar >> 0) & 0xFF; g = (scalar >> 8) & 0xFF; b = (scalar >> 16) & 0xFF; a = (scalar >> 24) & 0xFF; } - constexpr float GetNormalizedRed() const noexcept - { + constexpr float GetNormalizedRed() const noexcept { return r / 255.0f; } - constexpr float GetNormalizedGreen() const noexcept - { + constexpr float GetNormalizedGreen() const noexcept { return g / 255.0f; } - constexpr float GetNormalizedBlue() const noexcept - { + constexpr float GetNormalizedBlue() const noexcept { return b / 255.0f; } - constexpr float GetNormalizedAlpha() const noexcept - { + constexpr float GetNormalizedAlpha() const noexcept { return a / 255.0f; } - constexpr Vec4i AsVec4i() const noexcept - { + constexpr Vec4i AsVec4i() const noexcept { return Vec4i{ r, g, b, a }; } - constexpr Vec4f AsVec4f() const noexcept - { + constexpr Vec4f AsVec4f() const noexcept { return Vec4f{ GetNormalizedRed(), GetNormalizedGreen(), @@ -103,20 +90,17 @@ public: }; } - ImVec4 AsImVec() const - { + ImVec4 AsImVec() const { auto v = AsVec4f(); return ImVec4{ v.x, v.y, v.z, v.w }; } - ImColor AsImColor() const - { + ImColor AsImColor() const { auto v = AsVec4f(); return ImColor{ v.x, v.y, v.z, v.w }; } - ImU32 AsImU32() const - { + ImU32 AsImU32() const { ImU32 res; res |= r << IM_COL32_R_SHIFT; res |= g << IM_COL32_G_SHIFT; @@ -125,8 +109,7 @@ public: return res; } - constexpr void SetVec(const Vec4f& vec) noexcept - { + constexpr void SetVec(const Vec4f& vec) noexcept { r = (uint8_t)(vec.x * 255.0f); g = (uint8_t)(vec.y * 255.0f); b = (uint8_t)(vec.z * 255.0f); @@ -139,8 +122,7 @@ public: friend constexpr bool operator==(const RgbaColor&, const RgbaColor&) noexcept = default; }; -class HsvColor -{ +class HsvColor { public: float h; float s; @@ -152,24 +134,21 @@ public: : h{ 0.0f } , s{ 0.0f } , v{ 1.0f } - , a{ 1.0f } - { + , a{ 1.0f } { } constexpr HsvColor(float h, float s, float v, float a) noexcept : h{ h } , s{ s } , v{ v } - , a{ a } - { + , a{ a } { } // Forward declaring because cyclic reference between RgbaColor and HsvColor constexpr RgbaColor ToRgba() const noexcept; }; -constexpr HsvColor RgbaColor::ToHsv() const noexcept -{ +constexpr HsvColor RgbaColor::ToHsv() const noexcept { float fr = GetNormalizedRed(); float fg = GetNormalizedBlue(); float fb = GetNormalizedGreen(); @@ -185,8 +164,7 @@ constexpr HsvColor RgbaColor::ToHsv() const noexcept return HsvColor(hcv.x, s, hcv.z, fa); } -constexpr RgbaColor HsvColor::ToRgba() const noexcept -{ +constexpr RgbaColor HsvColor::ToRgba() const noexcept { float r = MathUtils::Abs(h * 6 - 3) - 1; float g = 2 - MathUtils::Abs(h * 6 - 2); float b = 2 - MathUtils::Abs(h * 6 - 4); -- cgit v1.2.3-70-g09d2