public static string ProcessColorString(object colorValue, StoppedDouble opacity) { string val = (string)colorValue; if (opacity != null && (opacity.Stops != null || (opacity.SingleVal > 0 && opacity.SingleVal < 1))) { if (opacity.Stops == null) { Color color = ColorFromString(val); color = Blend(color, opacity.SingleVal); return($"[{NumToString(color.R)},{NumToString(color.G)},{NumToString(color.B)}]"); } } if (val.StartsWith("rgba")) { return($"'{ColorTranslator.ToHtml(ColorFromRGBA(val))}'"); } if (val.StartsWith("hsla")) { return($"'{ColorTranslator.ToHtml(ColorFromHSLA(val))}'"); } if (val.StartsWith("hsl")) { return($"'{ColorTranslator.ToHtml(ColorFromHSL(val))}'"); } return($"'{val}'"); }
public static string ProcessWidth(StoppedDouble widthValue, bool isCasing) // if it casing fudge to make them smaller { if (widthValue != null) { if (widthValue.Stops != null) { if (widthValue.Stops.Count > 1) { List <string> values = new List <string>(); if (widthValue.Base > 1 && widthValue.Stops.Count >= 2) { CalculateAllStops(widthValue.Base, widthValue.Stops, values, isCasing); } else { foreach (var stop in widthValue.Stops) { int zoom; double value; ParseZoomAndValue(stop, out zoom, out value); if (isCasing) { zoom = zoom + CasingZoomAdjust; } values.Add(CreateArrayString(zoom, value)); } } return(JoinValueArray(values)); } var width = widthValue.Stops[widthValue.Stops.Count - 1]; return($"'{width[width.Count - 1]}px'"); } if (widthValue.SingleVal != double.MinValue) { return($"{widthValue.SingleVal.ToString("F2")}px"); } } Converter.AppendDebug($"Did not process - ProcessWidth", widthValue); return("'30px'"); }
public static string ProcessColor(object colorValue, StoppedDouble opacity) { if (colorValue != null) { if (colorValue is string) { return(ColorUtils.ProcessColorString(colorValue, opacity)); } if (colorValue is JObject) { JObject val = (JObject)colorValue; if (val.First.Path == "base") { //double scale = double.Parse(((JValue)val.First.Last).Value.ToString()); List <string> values = new List <string>(); foreach (JArray stop in val.Last.Last) { List <object> stopAsList = stop.ToObject <List <object> >(); int zoom = (int)Math.Ceiling(double.Parse(stopAsList[0].ToString())); string color = ColorUtils.ProcessColorString(stopAsList[1].ToString(), opacity); values.Add(CreateArrayString(zoom, color)); } return(JoinValueArray(values)); } return(ColorUtils.ProcessColorString(val.Last.Last.Last.Last.ToString(), opacity)); } Converter.AppendDebug($"Did not process - ProcessColor", colorValue); return("#3f3f3f"); } Converter.AppendDebug($"Did not process - ProcessColor", colorValue); return(""); }