summaryrefslogtreecommitdiff
path: root/modules/mono/glue
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2019-12-18 23:40:26 -0500
committerAaron Franke <arnfranke@yahoo.com>2020-01-03 06:00:14 -0500
commit68ba2588b89fd4c17275ca6b91f294ff3e7fc6b4 (patch)
tree75e064d2c75d04828fb5721f9b0c4fe2a4e145a4 /modules/mono/glue
parent9d3424f61ddd1e6bec78381aa4a0c6acec53d290 (diff)
[Mono] Color arithmetic operators
Diffstat (limited to 'modules/mono/glue')
-rw-r--r--modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs70
1 files changed, 69 insertions, 1 deletions
diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
index df817e47e9..0462ef1125 100644
--- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
+++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Color.cs
@@ -541,7 +541,7 @@ namespace Godot
return true;
}
- public static Color Color8(byte r8, byte g8, byte b8, byte a8)
+ public static Color Color8(byte r8, byte g8, byte b8, byte a8 = 255)
{
return new Color(r8 / 255f, g8 / 255f, b8 / 255f, a8 / 255f);
}
@@ -605,6 +605,74 @@ namespace Godot
throw new ArgumentOutOfRangeException("Invalid color code. Blue part is not valid hexadecimal: " + rgba);
}
+ public static Color operator +(Color left, Color right)
+ {
+ left.r += right.r;
+ left.g += right.g;
+ left.b += right.b;
+ left.a += right.a;
+ return left;
+ }
+
+ public static Color operator -(Color left, Color right)
+ {
+ left.r -= right.r;
+ left.g -= right.g;
+ left.b -= right.b;
+ left.a -= right.a;
+ return left;
+ }
+
+ public static Color operator -(Color color)
+ {
+ return Colors.White - color;
+ }
+
+ public static Color operator *(Color color, float scale)
+ {
+ color.r *= scale;
+ color.g *= scale;
+ color.b *= scale;
+ color.a *= scale;
+ return color;
+ }
+
+ public static Color operator *(float scale, Color color)
+ {
+ color.r *= scale;
+ color.g *= scale;
+ color.b *= scale;
+ color.a *= scale;
+ return color;
+ }
+
+ public static Color operator *(Color left, Color right)
+ {
+ left.r *= right.r;
+ left.g *= right.g;
+ left.b *= right.b;
+ left.a *= right.a;
+ return left;
+ }
+
+ public static Color operator /(Color color, float scale)
+ {
+ color.r /= scale;
+ color.g /= scale;
+ color.b /= scale;
+ color.a /= scale;
+ return color;
+ }
+
+ public static Color operator /(Color left, Color right)
+ {
+ left.r /= right.r;
+ left.g /= right.g;
+ left.b /= right.b;
+ left.a /= right.a;
+ return left;
+ }
+
public static bool operator ==(Color left, Color right)
{
return left.Equals(right);