You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
[Mono] Fix Color incorrect ordering of int export methods, added 64-bit
[Mono] Fix Color incorrect ordering of int export methods, added 64-bit long export methods.
This commit is contained in:
@@ -293,28 +293,80 @@ namespace Godot
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ToRgba32()
|
public int ToAbgr32()
|
||||||
{
|
{
|
||||||
int c = (byte)(r * 255);
|
int c = (byte)Math.Round(a * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(g * 255);
|
c |= (byte)Math.Round(b * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(b * 255);
|
c |= (byte)Math.Round(g * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(a * 255);
|
c |= (byte)Math.Round(r * 255);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ToAbgr64()
|
||||||
|
{
|
||||||
|
long c = (ushort)Math.Round(a * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(b * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(g * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(r * 65535);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ToArgb32()
|
public int ToArgb32()
|
||||||
{
|
{
|
||||||
int c = (byte)(a * 255);
|
int c = (byte)Math.Round(a * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(r * 255);
|
c |= (byte)Math.Round(r * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(g * 255);
|
c |= (byte)Math.Round(g * 255);
|
||||||
c <<= 8;
|
c <<= 8;
|
||||||
c |= (byte)(b * 255);
|
c |= (byte)Math.Round(b * 255);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ToArgb64()
|
||||||
|
{
|
||||||
|
long c = (ushort)Math.Round(a * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(r * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(g * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(b * 65535);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ToRgba32()
|
||||||
|
{
|
||||||
|
int c = (byte)Math.Round(r * 255);
|
||||||
|
c <<= 8;
|
||||||
|
c |= (byte)Math.Round(g * 255);
|
||||||
|
c <<= 8;
|
||||||
|
c |= (byte)Math.Round(b * 255);
|
||||||
|
c <<= 8;
|
||||||
|
c |= (byte)Math.Round(a * 255);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long ToRgba64()
|
||||||
|
{
|
||||||
|
long c = (ushort)Math.Round(r * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(g * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(b * 65535);
|
||||||
|
c <<= 16;
|
||||||
|
c |= (ushort)Math.Round(a * 65535);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
@@ -353,6 +405,17 @@ namespace Godot
|
|||||||
r = (rgba & 0xFF) / 255.0f;
|
r = (rgba & 0xFF) / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color(long rgba)
|
||||||
|
{
|
||||||
|
a = (rgba & 0xFFFF) / 65535.0f;
|
||||||
|
rgba >>= 16;
|
||||||
|
b = (rgba & 0xFFFF) / 65535.0f;
|
||||||
|
rgba >>= 16;
|
||||||
|
g = (rgba & 0xFFFF) / 65535.0f;
|
||||||
|
rgba >>= 16;
|
||||||
|
r = (rgba & 0xFFFF) / 65535.0f;
|
||||||
|
}
|
||||||
|
|
||||||
private static int _parse_col(string str, int ofs)
|
private static int _parse_col(string str, int ofs)
|
||||||
{
|
{
|
||||||
int ig = 0;
|
int ig = 0;
|
||||||
@@ -392,7 +455,7 @@ namespace Godot
|
|||||||
|
|
||||||
private String _to_hex(float val)
|
private String _to_hex(float val)
|
||||||
{
|
{
|
||||||
var v = (int) Mathf.Clamp(val * 255.0f, 0, 255);
|
int v = Mathf.RoundToInt(Mathf.Clamp(val * 255, 0, 255));
|
||||||
|
|
||||||
var ret = string.Empty;
|
var ret = string.Empty;
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5
|
6
|
||||||
|
|||||||
Reference in New Issue
Block a user