mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-25 22:18:34 +01:00
fixed tiled color parsing
This commit is contained in:
parent
17a5b3ec74
commit
422f0834b3
2 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,7 @@ using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using MonoGame.Extended;
|
using MonoGame.Extended;
|
||||||
using MonoGame.Extended.Tiled;
|
using MonoGame.Extended.Tiled;
|
||||||
|
using ColorExtensions = MLEM.Extensions.ColorExtensions;
|
||||||
|
|
||||||
namespace MLEM.Extended.Tiled {
|
namespace MLEM.Extended.Tiled {
|
||||||
public static class TiledExtensions {
|
public static class TiledExtensions {
|
||||||
|
@ -23,7 +24,7 @@ namespace MLEM.Extended.Tiled {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color GetColor(this TiledMapProperties properties, string key) {
|
public static Color GetColor(this TiledMapProperties properties, string key) {
|
||||||
return ColorHelper.FromHex(properties.Get(key));
|
return ColorExtensions.FromHex(properties.Get(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float GetFloat(this TiledMapProperties properties, string key) {
|
public static float GetFloat(this TiledMapProperties properties, string key) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
|
||||||
namespace MLEM.Extensions {
|
namespace MLEM.Extensions {
|
||||||
|
@ -12,6 +13,12 @@ namespace MLEM.Extensions {
|
||||||
return new Color((int) (value >> 16 & 0xFF), (int) (value >> 8 & 0xFF), (int) (value >> 0 & 0xFF), (int) (value >> 24 & 0xFF));
|
return new Color((int) (value >> 16 & 0xFF), (int) (value >> 8 & 0xFF), (int) (value >> 0 & 0xFF), (int) (value >> 24 & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Color FromHex(string value) {
|
||||||
|
if (value.StartsWith("#"))
|
||||||
|
value = value.Substring(1);
|
||||||
|
return FromHex(uint.Parse(value, NumberStyles.HexNumber));
|
||||||
|
}
|
||||||
|
|
||||||
public static Color CopyAlpha(this Color color, Color other) {
|
public static Color CopyAlpha(this Color color, Color other) {
|
||||||
return color * (other.A / 255F);
|
return color * (other.A / 255F);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue