diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 13:23:58 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-05-14 16:54:55 +0200 |
commit | 0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch) | |
tree | a27e497da7104dd0a64f98a04fa3067668735e91 /core/color.cpp | |
parent | 710b34b70227becdc652b4ae027fe0ac47409642 (diff) | |
download | redot-engine-0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a.tar.gz |
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to
will now be changed automatically to remove the first empty line.
This makes us lean closer to 1TBS (the one true brace style) instead
of hybridating it with some Allman-inspired spacing.
There's still the case of braces around single-statement blocks that
needs to be addressed (but clang-format can't help with that, but
clang-tidy may if we agree about it).
Part of #33027.
Diffstat (limited to 'core/color.cpp')
-rw-r--r-- | core/color.cpp | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/core/color.cpp b/core/color.cpp index 79b9f70a99..328b2e3568 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -36,7 +36,6 @@ #include "core/print_string.h" uint32_t Color::to_argb32() const { - uint32_t c = (uint8_t)Math::round(a * 255); c <<= 8; c |= (uint8_t)Math::round(r * 255); @@ -49,7 +48,6 @@ uint32_t Color::to_argb32() const { } uint32_t Color::to_abgr32() const { - uint32_t c = (uint8_t)Math::round(a * 255); c <<= 8; c |= (uint8_t)Math::round(b * 255); @@ -62,7 +60,6 @@ uint32_t Color::to_abgr32() const { } uint32_t Color::to_rgba32() const { - uint32_t c = (uint8_t)Math::round(r * 255); c <<= 8; c |= (uint8_t)Math::round(g * 255); @@ -75,7 +72,6 @@ uint32_t Color::to_rgba32() const { } uint64_t Color::to_abgr64() const { - uint64_t c = (uint16_t)Math::round(a * 65535); c <<= 16; c |= (uint16_t)Math::round(b * 65535); @@ -88,7 +84,6 @@ uint64_t Color::to_abgr64() const { } uint64_t Color::to_argb64() const { - uint64_t c = (uint16_t)Math::round(a * 65535); c <<= 16; c |= (uint16_t)Math::round(r * 65535); @@ -101,7 +96,6 @@ uint64_t Color::to_argb64() const { } uint64_t Color::to_rgba64() const { - uint64_t c = (uint16_t)Math::round(r * 65535); c <<= 16; c |= (uint16_t)Math::round(g * 65535); @@ -114,7 +108,6 @@ uint64_t Color::to_rgba64() const { } float Color::get_h() const { - float min = MIN(r, g); min = MIN(min, b); float max = MAX(r, g); @@ -141,7 +134,6 @@ float Color::get_h() const { } float Color::get_s() const { - float min = MIN(r, g); min = MIN(min, b); float max = MAX(r, g); @@ -153,14 +145,12 @@ float Color::get_s() const { } float Color::get_v() const { - float max = MAX(r, g); max = MAX(max, b); return max; } void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { - int i; float f, p, q, t; a = p_alpha; @@ -215,25 +205,21 @@ void Color::set_hsv(float p_h, float p_s, float p_v, float p_alpha) { } bool Color::is_equal_approx(const Color &p_color) const { - return Math::is_equal_approx(r, p_color.r) && Math::is_equal_approx(g, p_color.g) && Math::is_equal_approx(b, p_color.b) && Math::is_equal_approx(a, p_color.a); } void Color::invert() { - r = 1.0 - r; g = 1.0 - g; b = 1.0 - b; } void Color::contrast() { - r = Math::fmod(r + 0.5, 1.0); g = Math::fmod(g + 0.5, 1.0); b = Math::fmod(b + 0.5, 1.0); } Color Color::hex(uint32_t p_hex) { - float a = (p_hex & 0xFF) / 255.0; p_hex >>= 8; float b = (p_hex & 0xFF) / 255.0; @@ -246,7 +232,6 @@ Color Color::hex(uint32_t p_hex) { } Color Color::hex64(uint64_t p_hex) { - float a = (p_hex & 0xFFFF) / 65535.0; p_hex >>= 16; float b = (p_hex & 0xFFFF) / 65535.0; @@ -259,7 +244,6 @@ Color Color::hex64(uint64_t p_hex) { } Color Color::from_rgbe9995(uint32_t p_rgbe) { - float r = p_rgbe & 0x1ff; float g = (p_rgbe >> 9) & 0x1ff; float b = (p_rgbe >> 18) & 0x1ff; @@ -274,11 +258,9 @@ Color Color::from_rgbe9995(uint32_t p_rgbe) { } static float _parse_col(const String &p_str, int p_ofs) { - int ig = 0; for (int i = 0; i < 2; i++) { - int c = p_str[i + p_ofs]; int v = 0; @@ -304,21 +286,18 @@ static float _parse_col(const String &p_str, int p_ofs) { } Color Color::inverted() const { - Color c = *this; c.invert(); return c; } Color Color::contrasted() const { - Color c = *this; c.contrast(); return c; } Color Color::html(const String &p_color) { - String color = p_color; if (color.length() == 0) return Color(); @@ -362,7 +341,6 @@ Color Color::html(const String &p_color) { } bool Color::html_is_valid(const String &p_color) { - String color = p_color; if (color.length() == 0) @@ -423,13 +401,11 @@ Color Color::named(const String &p_name) { } String _to_hex(float p_val) { - int v = Math::round(p_val * 255); v = CLAMP(v, 0, 255); String ret; for (int i = 0; i < 2; i++) { - CharType c[2] = { 0, 0 }; int lv = v & 0xF; if (lv < 10) @@ -446,7 +422,6 @@ String _to_hex(float p_val) { } String Color::to_html(bool p_alpha) const { - String txt; txt += _to_hex(r); txt += _to_hex(g); @@ -457,7 +432,6 @@ String Color::to_html(bool p_alpha) const { } Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const { - p_h = Math::fmod(p_h * 360.0f, 360.0f); if (p_h < 0.0) p_h += 360.0f; @@ -510,12 +484,10 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) const { } Color::operator String() const { - return rtos(r) + ", " + rtos(g) + ", " + rtos(b) + ", " + rtos(a); } Color Color::operator+(const Color &p_color) const { - return Color( r + p_color.r, g + p_color.g, @@ -524,7 +496,6 @@ Color Color::operator+(const Color &p_color) const { } Color Color::operator-(const Color &p_color) const { - return Color( r - p_color.r, g - p_color.g, @@ -533,7 +504,6 @@ Color Color::operator-(const Color &p_color) const { } void Color::operator-=(const Color &p_color) { - r = r - p_color.r; g = g - p_color.g; b = b - p_color.b; @@ -541,7 +511,6 @@ void Color::operator-=(const Color &p_color) { } Color Color::operator*(const Color &p_color) const { - return Color( r * p_color.r, g * p_color.g, @@ -550,7 +519,6 @@ Color Color::operator*(const Color &p_color) const { } Color Color::operator*(const real_t &rvalue) const { - return Color( r * rvalue, g * rvalue, @@ -559,7 +527,6 @@ Color Color::operator*(const real_t &rvalue) const { } void Color::operator*=(const Color &p_color) { - r = r * p_color.r; g = g * p_color.g; b = b * p_color.b; @@ -567,7 +534,6 @@ void Color::operator*=(const Color &p_color) { } void Color::operator*=(const real_t &rvalue) { - r = r * rvalue; g = g * rvalue; b = b * rvalue; @@ -575,7 +541,6 @@ void Color::operator*=(const real_t &rvalue) { } Color Color::operator/(const Color &p_color) const { - return Color( r / p_color.r, g / p_color.g, @@ -584,7 +549,6 @@ Color Color::operator/(const Color &p_color) const { } Color Color::operator/(const real_t &rvalue) const { - return Color( r / rvalue, g / rvalue, @@ -593,7 +557,6 @@ Color Color::operator/(const real_t &rvalue) const { } void Color::operator/=(const Color &p_color) { - r = r / p_color.r; g = g / p_color.g; b = b / p_color.b; @@ -601,7 +564,6 @@ void Color::operator/=(const Color &p_color) { } void Color::operator/=(const real_t &rvalue) { - if (rvalue == 0) { r = 1.0; g = 1.0; @@ -616,7 +578,6 @@ void Color::operator/=(const real_t &rvalue) { }; Color Color::operator-() const { - return Color( 1.0 - r, 1.0 - g, |