diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-08-21 20:29:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 20:29:56 +0200 |
commit | 28e9aedbddb41f240ff7b416c8359673d3505a79 (patch) | |
tree | 8de874b726bdb1be6ceef3fad3c6a5adf08aafe2 /core | |
parent | 44d75e3b6d2565e13e4f49d21d5e00dfcc99afd9 (diff) | |
parent | 2969dffbe3dc8cc5fc45f284a935f177f79efab4 (diff) |
Merge pull request #21267 from akien-mga/color-grayscale
Deprecate incorrect Color::gray()
Diffstat (limited to 'core')
-rw-r--r-- | core/color.cpp | 3 | ||||
-rw-r--r-- | core/image.cpp | 4 |
2 files changed, 5 insertions, 2 deletions
diff --git a/core/color.cpp b/core/color.cpp index fcfcf20355..0d8cad1a5e 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -506,8 +506,11 @@ Color Color::from_hsv(float p_h, float p_s, float p_v, float p_a) { return Color(m + r, m + g, m + b, p_a); } +// FIXME: Remove once Godot 3.1 has been released float Color::gray() const { + ERR_EXPLAIN("Color.gray() is deprecated and will be removed in a future version. Use Color.get_v() for a better grayscale approximation."); + WARN_DEPRECATED return (r + g + b) / 3.0; } diff --git a/core/image.cpp b/core/image.cpp index c94f2c3534..2fd7ea5c14 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2230,10 +2230,10 @@ void Image::set_pixel(int p_x, int p_y, const Color &p_color) { switch (format) { case FORMAT_L8: { - ptr[ofs] = uint8_t(CLAMP(p_color.gray() * 255.0, 0, 255)); + ptr[ofs] = uint8_t(CLAMP(p_color.get_v() * 255.0, 0, 255)); } break; case FORMAT_LA8: { - ptr[ofs * 2 + 0] = uint8_t(CLAMP(p_color.gray() * 255.0, 0, 255)); + ptr[ofs * 2 + 0] = uint8_t(CLAMP(p_color.get_v() * 255.0, 0, 255)); ptr[ofs * 2 + 1] = uint8_t(CLAMP(p_color.a * 255.0, 0, 255)); } break; case FORMAT_R8: { |