Skip to content

Commit

Permalink
Merge pull request #74973 from timothyqiu/a-color
Browse files Browse the repository at this point in the history
[3.x] Add Color + alpha constructor for Color
  • Loading branch information
akien-mga committed Apr 11, 2023
2 parents baf2fe8 + 3544cd1 commit 0facd88
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 3 additions & 5 deletions core/variant_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,11 +1103,8 @@ struct _VariantCall {
}

static void Color_init3(Variant &r_ret, const Variant **p_args) {
r_ret = Color::html(*p_args[0]);
}

static void Color_init4(Variant &r_ret, const Variant **p_args) {
r_ret = Color::hex(*p_args[0]);
Color c = *p_args[0];
r_ret = Color(c.r, c.g, c.b, *p_args[1]);
}

static void AABB_init1(Variant &r_ret, const Variant **p_args) {
Expand Down Expand Up @@ -2212,6 +2209,7 @@ void register_variant_methods() {

_VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init3, Variant::COLOR, "from", Variant::COLOR, "alpha", Variant::REAL);

_VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3);

Expand Down
11 changes: 11 additions & 0 deletions doc/classes/Color.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@
[/codeblock]
</description>
</method>
<method name="Color">
<return type="Color" />
<argument index="0" name="from" type="Color" />
<argument index="1" name="alpha" type="float" />
<description>
Constructs a color from the existing color, with [member a] set to the given [code]alpha[/code] value.
[codeblock]
var red = Color(Color.red, 0.2) # 20% opaque red.
[/codeblock]
</description>
</method>
<method name="Color">
<return type="Color" />
<argument index="0" name="r" type="float" />
Expand Down

0 comments on commit 0facd88

Please sign in to comment.