Make Color use uint for ARGB.
This is a more natural representation than int that allows removal of casts in many places that require uint. Additionally, we can change the internal representation from long to uint, making the Color struct smaller. Since arrays of colors are common, this can save on memory.
This commit is contained in:
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
public void LoadPalettes(WorldRenderer wr)
|
||||
{
|
||||
var c = info.Fog ? Fog : Shroud;
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (uint)c[i % 8].ToArgb())));
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => c[i % 8].ToArgb())));
|
||||
}
|
||||
|
||||
static readonly Color[] Fog = new[]
|
||||
|
||||
@@ -77,8 +77,8 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
|
||||
|
||||
static int ColorDistance(uint a, uint b)
|
||||
{
|
||||
var ca = Color.FromArgb((int)a);
|
||||
var cb = Color.FromArgb((int)b);
|
||||
var ca = Color.FromArgb(a);
|
||||
var cb = Color.FromArgb(b);
|
||||
|
||||
return Math.Abs(ca.R - cb.R) +
|
||||
Math.Abs(ca.G - cb.G) +
|
||||
|
||||
Reference in New Issue
Block a user