|
@@ -16,7 +16,11 @@ namespace Godot
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- return (int)(r * 255.0f);
|
|
|
+ return (int)Math.Round(r * 255.0f);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ r = value / 255.0f;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -24,7 +28,11 @@ namespace Godot
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- return (int)(g * 255.0f);
|
|
|
+ return (int)Math.Round(g * 255.0f);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ g = value / 255.0f;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -32,7 +40,11 @@ namespace Godot
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- return (int)(b * 255.0f);
|
|
|
+ return (int)Math.Round(b * 255.0f);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ b = value / 255.0f;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -40,7 +52,11 @@ namespace Godot
|
|
|
{
|
|
|
get
|
|
|
{
|
|
|
- return (int)(a * 255.0f);
|
|
|
+ return (int)Math.Round(a * 255.0f);
|
|
|
+ }
|
|
|
+ set
|
|
|
+ {
|
|
|
+ a = value / 255.0f;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -74,7 +90,7 @@ namespace Godot
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
- this = FromHsv(value, s, v);
|
|
|
+ this = FromHsv(value, s, v, a);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -91,7 +107,7 @@ namespace Godot
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
- this = FromHsv(h, value, v);
|
|
|
+ this = FromHsv(h, value, v, a);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -103,7 +119,7 @@ namespace Godot
|
|
|
}
|
|
|
set
|
|
|
{
|
|
|
- this = FromHsv(h, s, value);
|
|
|
+ this = FromHsv(h, s, value, a);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -166,12 +182,12 @@ namespace Godot
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void ToHsv(Color color, out float hue, out float saturation, out float value)
|
|
|
+ public void ToHsv(out float hue, out float saturation, out float value)
|
|
|
{
|
|
|
- int max = Mathf.Max(color.r8, Mathf.Max(color.g8, color.b8));
|
|
|
- int min = Mathf.Min(color.r8, Mathf.Min(color.g8, color.b8));
|
|
|
+ float max = (float)Mathf.Max(r, Mathf.Max(g, b));
|
|
|
+ float min = (float)Mathf.Min(r, Mathf.Min(g, b));
|
|
|
|
|
|
- int delta = max - min;
|
|
|
+ float delta = max - min;
|
|
|
|
|
|
if (delta == 0)
|
|
|
{
|
|
@@ -179,12 +195,12 @@ namespace Godot
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (color.r == max)
|
|
|
- hue = (color.g - color.b) / delta; // Between yellow & magenta
|
|
|
- else if (color.g == max)
|
|
|
- hue = 2 + (color.b - color.r) / delta; // Between cyan & yellow
|
|
|
+ if (r == max)
|
|
|
+ hue = (g - b) / delta; // Between yellow & magenta
|
|
|
+ else if (g == max)
|
|
|
+ hue = 2 + (b - r) / delta; // Between cyan & yellow
|
|
|
else
|
|
|
- hue = 4 + (color.r - color.g) / delta; // Between magenta & cyan
|
|
|
+ hue = 4 + (r - g) / delta; // Between magenta & cyan
|
|
|
|
|
|
hue /= 6.0f;
|
|
|
|
|
@@ -193,7 +209,7 @@ namespace Godot
|
|
|
}
|
|
|
|
|
|
saturation = max == 0 ? 0 : 1f - 1f * min / max;
|
|
|
- value = max / 255f;
|
|
|
+ value = max;
|
|
|
}
|
|
|
|
|
|
public static Color FromHsv(float hue, float saturation, float value, float alpha = 1.0f)
|
|
@@ -257,7 +273,8 @@ namespace Godot
|
|
|
return new Color(
|
|
|
(r + 0.5f) % 1.0f,
|
|
|
(g + 0.5f) % 1.0f,
|
|
|
- (b + 0.5f) % 1.0f
|
|
|
+ (b + 0.5f) % 1.0f,
|
|
|
+ a
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -275,7 +292,8 @@ namespace Godot
|
|
|
return new Color(
|
|
|
1.0f - r,
|
|
|
1.0f - g,
|
|
|
- 1.0f - b
|
|
|
+ 1.0f - b,
|
|
|
+ a
|
|
|
);
|
|
|
}
|
|
|
|