mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
Merge pull request #43283 from Calinou/color-remove-contrasted
Remove `Color.contrasted()` as its behavior is barely useful
This commit is contained in:
commit
52c1b5fc41
@ -217,12 +217,6 @@ void Color::invert() {
|
||||
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;
|
||||
@ -284,12 +278,6 @@ Color Color::inverted() const {
|
||||
return c;
|
||||
}
|
||||
|
||||
Color Color::contrasted() const {
|
||||
Color c = *this;
|
||||
c.contrast();
|
||||
return c;
|
||||
}
|
||||
|
||||
Color Color::html(const String &p_rgba) {
|
||||
String color = p_rgba;
|
||||
if (color.length() == 0) {
|
||||
|
@ -91,9 +91,7 @@ struct Color {
|
||||
bool is_equal_approx(const Color &p_color) const;
|
||||
|
||||
void invert();
|
||||
void contrast();
|
||||
Color inverted() const;
|
||||
Color contrasted() const;
|
||||
|
||||
_FORCE_INLINE_ Color lerp(const Color &p_b, float p_t) const {
|
||||
Color res = *this;
|
||||
|
@ -1614,7 +1614,6 @@ void register_variant_methods() {
|
||||
bind_method(Color, to_rgba64, sarray(), varray());
|
||||
|
||||
bind_method(Color, inverted, sarray(), varray());
|
||||
bind_method(Color, contrasted, sarray(), varray());
|
||||
bind_method(Color, lerp, sarray("b", "t"), varray());
|
||||
bind_method(Color, lightened, sarray("amount"), varray());
|
||||
bind_method(Color, darkened, sarray("amount"), varray());
|
||||
|
@ -159,23 +159,6 @@
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="contrasted">
|
||||
<return type="Color">
|
||||
</return>
|
||||
<description>
|
||||
Returns the most contrasting color.
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var color = Color(0.3, 0.4, 0.9)
|
||||
var contrasted_color = color.contrasted() # Equivalent to RGBA(204, 229, 102, 255)
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
var color = new Color(0.3f, 0.4f, 0.9f);
|
||||
Color contrastedColor = color.Contrasted(); // Equivalent to RGBA(204, 229, 102, 255)
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
</description>
|
||||
</method>
|
||||
<method name="darkened">
|
||||
<return type="Color">
|
||||
</return>
|
||||
|
@ -148,13 +148,6 @@ godot_color GDAPI godot_color_inverted(const godot_color *p_self) {
|
||||
return dest;
|
||||
}
|
||||
|
||||
godot_color GDAPI godot_color_contrasted(const godot_color *p_self) {
|
||||
godot_color dest;
|
||||
const Color *self = (const Color *)p_self;
|
||||
*((Color *)&dest) = self->contrasted();
|
||||
return dest;
|
||||
}
|
||||
|
||||
godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t) {
|
||||
godot_color dest;
|
||||
const Color *self = (const Color *)p_self;
|
||||
|
@ -1254,13 +1254,6 @@
|
||||
["const godot_color *", "p_self"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_color_contrasted",
|
||||
"return_type": "godot_color",
|
||||
"arguments": [
|
||||
["const godot_color *", "p_self"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_color_lerp",
|
||||
"return_type": "godot_color",
|
||||
|
@ -93,8 +93,6 @@ godot_int GDAPI godot_color_to_argb32(const godot_color *p_self);
|
||||
|
||||
godot_color GDAPI godot_color_inverted(const godot_color *p_self);
|
||||
|
||||
godot_color GDAPI godot_color_contrasted(const godot_color *p_self);
|
||||
|
||||
godot_color GDAPI godot_color_lerp(const godot_color *p_self, const godot_color *p_b, const godot_real p_t);
|
||||
|
||||
godot_color GDAPI godot_color_blend(const godot_color *p_self, const godot_color *p_over);
|
||||
|
@ -256,20 +256,6 @@ namespace Godot
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the most contrasting color.
|
||||
/// </summary>
|
||||
/// <returns>The most contrasting color</returns>
|
||||
public Color Contrasted()
|
||||
{
|
||||
return new Color(
|
||||
(r + 0.5f) % 1.0f,
|
||||
(g + 0.5f) % 1.0f,
|
||||
(b + 0.5f) % 1.0f,
|
||||
a
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a new color resulting from making this color darker
|
||||
/// by the specified ratio (on the range of 0 to 1).
|
||||
|
@ -357,7 +357,7 @@ void GradientEdit::_notification(int p_what) {
|
||||
|
||||
//Draw point markers
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
Color col = points[i].color.contrasted();
|
||||
Color col = points[i].color.inverted();
|
||||
col.a = 0.9;
|
||||
|
||||
draw_line(Vector2(points[i].offset * total_w, 0), Vector2(points[i].offset * total_w, h / 2), col);
|
||||
|
@ -185,9 +185,6 @@ TEST_CASE("[Color] Manipulation methods") {
|
||||
CHECK_MESSAGE(
|
||||
blue.inverted().is_equal_approx(Color(1, 1, 0, 0.4)),
|
||||
"Inverted color should have its red, green and blue components inverted.");
|
||||
CHECK_MESSAGE(
|
||||
blue.contrasted().is_equal_approx(Color(0.5, 0.5, 0.5, 0.4)),
|
||||
"Contrasted pure blue should be fully gray.");
|
||||
|
||||
const Color purple = Color(0.5, 0.2, 0.5, 0.25);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user