mirror of
https://github.com/godotengine/godot.git
synced 2024-12-16 16:13:56 +00:00
Merge pull request #34452 from aaronfranke/color-arith
[Mono] Color arithmetic operators
This commit is contained in:
commit
09b4327805
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user