private static bool ToBoolean(CssValue value) { if (value is CssBoolean cssBoolean) { return(cssBoolean.Value); } var text = value.ToString(); return(text == "true" || text == "True"); }
private static bool ToBoolean(CssValue value) { if (value.Kind == NodeKind.Boolean) return ((CssBoolean)value).Value; return value.ToString().ToLower() == "true"; }
private static float GetAmount(CssValue value) { // TODO: consider value.kind var text = value.ToString(); switch (value.Kind) { case NodeKind.Angle : return (float.Parse(text.Replace("deg", "")) % 360) / 360; case NodeKind.Percentage : return ((CssMeasurement)value).Value / 100; case NodeKind.Number : return ((CssNumber)value).Value; default: throw new Exception("Unknown numeric value:" + value.ToString()); } }
private static Rgba GetColor(CssValue value) => Color.Rgba.Parse(value.ToString());
private static Rgba32 GetColor(CssValue value) => Rgba32.Parse(value.ToString());