summaryrefslogtreecommitdiff
path: root/modules/mono/glue/cs_files
diff options
context:
space:
mode:
authorIgnacio Etcheverry <neikeq@users.noreply.github.com>2018-05-18 20:09:01 +0200
committerGitHub <noreply@github.com>2018-05-18 20:09:01 +0200
commitfc90f41f53a639649bbc764746bfc59d22b98081 (patch)
tree55c3729ff3c7fa4c3e995c667a6edde09380a066 /modules/mono/glue/cs_files
parentd6c15bd96a3d0d98bfdb9559604acdc5dc0cda06 (diff)
parent88bd33f451fe15b0d31e5244366656ccc95484a7 (diff)
Merge pull request #18975 from KellyThomas/c-sharp-feature-parity-color
mono: New Color methods: Darkened, Lightened and ToRgba32
Diffstat (limited to 'modules/mono/glue/cs_files')
-rw-r--r--modules/mono/glue/cs_files/Color.cs26
1 files changed, 22 insertions, 4 deletions
diff --git a/modules/mono/glue/cs_files/Color.cs b/modules/mono/glue/cs_files/Color.cs
index af94bb616e..e0d6d27840 100644
--- a/modules/mono/glue/cs_files/Color.cs
+++ b/modules/mono/glue/cs_files/Color.cs
@@ -249,6 +249,15 @@ namespace Godot
);
}
+ public Color Darkened(float amount)
+ {
+ Color res = this;
+ res.r = res.r * (1.0f - amount);
+ res.g = res.g * (1.0f - amount);
+ res.b = res.b * (1.0f - amount);
+ return res;
+ }
+
public float Gray()
{
return (r + g + b) / 3.0f;
@@ -263,6 +272,15 @@ namespace Godot
);
}
+ public Color Lightened(float amount)
+ {
+ Color res = this;
+ res.r = res.r + (1.0f - res.r) * amount;
+ res.g = res.g + (1.0f - res.g) * amount;
+ res.b = res.b + (1.0f - res.b) * amount;
+ return res;
+ }
+
public Color LinearInterpolate(Color c, float t)
{
var res = this;
@@ -275,15 +293,15 @@ namespace Godot
return res;
}
- public int To32()
+ public int ToRgba32()
{
- int c = (byte)(a * 255);
- c <<= 8;
- c |= (byte)(r * 255);
+ int c = (byte)(r * 255);
c <<= 8;
c |= (byte)(g * 255);
c <<= 8;
c |= (byte)(b * 255);
+ c <<= 8;
+ c |= (byte)(a * 255);
return c;
}