Ejemplo n.º 1
0
        public void CheckHexConversion()
        {
            var raw = RawColor.FromHex("12AB34");

            Assert.AreEqual(18, raw.R);
            Assert.AreEqual(171, raw.G);
            Assert.AreEqual(52, raw.B);

            var hex = raw.ToHex();

            Assert.AreEqual("12AB34", hex);
        }
Ejemplo n.º 2
0
 public static Color?Parse(string colorName)
 {
     if (Regex.Match(colorName, @"#?[\dA-Fa-f]{6}").Success)
     {
         return(RawColor.FromHex(colorName.Substring(1)).ToXnaColor());
     }
     else
     {
         var propertyInfo = typeof(Color).GetProperty(colorName, BindingFlags.Static | BindingFlags.Public);
         return((Color?)propertyInfo?.GetValue(null));
     }
 }
Ejemplo n.º 3
0
        private Color?GetColor(OutputItem outputItem, Object dropInItem)
        {
            var color = outputItem?.Color;

            if (string.IsNullOrWhiteSpace(color))
            {
                return(null);
            }

            return((color != "@")
                ? RawColor.FromHex(color).ToXnaColor()
                : DominantColorFinder.GetDominantColor(dropInItem.ParentSheetIndex, Game1.objectSpriteSheet, 16, 16));
        }
Ejemplo n.º 4
0
        private Color?ConvertColor(string color)
        {
            if (color == null)
            {
                return(null);
            }
            if (color != "@")
            {
                return(RawColor.FromHex(color).ToXnaColor());
            }
            if (heldObject == null)
            {
                return(null);
            }
            var heldColor = heldObject.GetColor();

            if (heldColor != null)
            {
                return(heldColor);
            }
            return(DominantColorFinder.GetDominantColor(heldObject.ParentSheetIndex, Game1.objectSpriteSheet, 16, 16));
        }