//stroke-linecap //stroke-linejoin //stroke-dasharray public SVGStroke(Dictionary <string, string> _attrList) { _color = new SVGColor(_attrList["stroke"]); if (_attrList.ContainsKey("stroke-width")) { float.TryParse(_attrList["stroke-width"], out _width); } if (_attrList.ContainsKey("stroke-opacity")) { float.TryParse(_attrList["stroke-opacity"], out _opacity); } if (_attrList.ContainsKey("stroke-linecap")) { Debug.LogWarning("stroke-linecap not implemented"); } if (_attrList.ContainsKey("stroke-linejoin")) { Debug.LogWarning("stroke-linejoin not implemented"); } if (_attrList.ContainsKey("stroke-dasharray")) { Debug.LogWarning("stroke-dasharray not implemented"); } }
//----- public void Circle(Vector2 p, float r, SVGColor? strokeColor) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Circle(p, r); }
protected Color GetColor(SVGColor svgColor) { if (svgColor.color.a != 1) { _alphaBlended = true; } return(svgColor.color); }
//----- public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor?strokeColor) { SetColor(fillColor.color); PreRoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); EndSubBuffer(strokeColor); }
public void FillRoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor?strokeColor) { graphicsFill.RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, fillColor, strokeColor); }
protected Color GetColor(SVGColor svgColor) { if(svgColor.color.a != 1) { _alphaBlended = true; } return svgColor.color; }
public SVGStopElement(Dictionary<string, string> attrList) { _stopColor = new SVGColor(attrList.GetValue("stop-color")); string temp = attrList.GetValue("offset").Trim(); if(temp != "") { if(temp.EndsWith("%")) _offset = float.Parse(temp.TrimEnd(new[] { '%' }), System.Globalization.CultureInfo.InvariantCulture); else _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture) * 100; } }
/***************************************************************************/ public SVGStopElement(AttributeList attrList) { _stopColor = new SVGColor(attrList.GetValue("stop-color")); string temp = attrList.GetValue("offset").Trim(); if(temp != "") { if(temp.EndsWith("%")) { _offset = float.Parse(temp.TrimEnd(new char[1] { '%' }), System.Globalization.CultureInfo.InvariantCulture); } else { _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture)* 100; } } }
/***************************************************************************/ public SVGStopElement(AttributeList attrList) { _stopColor = new SVGColor(attrList.GetValue("stop-color")); string temp = attrList.GetValue("offset").Trim(); if(temp != "") { if(temp.EndsWith("%")) { _offset = SVGNumber.ParseToFloat(temp.TrimEnd(new char[1]{'%'})); } else { _offset = SVGNumber.ParseToFloat(temp)* 100; } } }
public void FillPath(SVGColor fillColor, SVGColor?strokePathColor, SVGGraphicsPath graphicsPath) { ResetSubBuffer(); graphicsPath.RenderPath(this, true); if (strokePathColor != null) { EndSubBuffer(strokePathColor); } else { EndSubBuffer(); } }
public void FillEllipse(Vector2 p, float rx, float ry, float angle, SVGColor fillColor, SVGColor?strokeColor, float width) { if ((int)width == 1) { FillEllipse(p, rx, ry, angle, strokeColor); return; } SetColor(fillColor.color); FillEllipse(p, rx, ry, angle); if (strokeColor == null) { return; } SetColor(strokeColor.Value.color); Ellipse(p, rx, ry, angle, width); }
public void FillCircle(Vector2 p, float r, SVGColor fillColor, SVGColor?strokeColor, float width) { if ((int)width == 1) { FillCircle(p, r, strokeColor); return; } SetColor(fillColor.color); FillCircle(p, r); if (strokeColor == null) { return; } SetColor(strokeColor.Value.color); Circle(p, r, strokeColor, width); }
public void FillRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor?strokeColor, float width) { if ((int)width == 1) { FillRect(p1, p2, p3, p4, fillColor, strokeColor); return; } SetColor(fillColor.color); FillRect(p1, p2, p3, p4); if (strokeColor == null) { return; } SetColor(strokeColor.Value.color); Rect(p1, p2, p3, p4, strokeColor, width); }
public SVGStopElement(Dictionary <string, string> attrList) { _stopColor = new SVGColor(attrList.GetValue("stop-color")); string temp = attrList.GetValue("offset").Trim(); if (temp != "") { if (temp.EndsWith("%")) { _offset = float.Parse(temp.TrimEnd(new[] { '%' }), System.Globalization.CultureInfo.InvariantCulture); } else { _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture) * 100; } } }
public void FillPolygon(Vector2[] points, SVGColor fillColor, SVGColor?strokeColor, float width) { if ((int)width == 1) { FillPolygon(points, strokeColor); return; } SetColor(fillColor.color); FillPolygon(points); if (strokeColor == null) { return; } SetColor(strokeColor.Value.color); Polygon(points, width); }
public void FillRoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor?strokeColor, float width) { if ((int)width == 1) { FillRoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, strokeColor); return; } SetColor(fillColor.color); graphicsFill.RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); if (strokeColor == null) { return; } SetColor(strokeColor.Value.color); RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, strokeColor); }
//Fill khong co Stroke, va ve stroke sau public void FillPath(SVGColor fillColor, SVGColor?strokePathColor, float width, SVGGraphicsPath graphicsPath) { graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); if ((int)width == 1) { graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); } else { graphicsFill.FillPath(fillColor, graphicsPath); } if (strokePathColor == null) { return; } SetColor(strokePathColor.Value.color); }
private Texture2D DrawSVG(uint texWidth, uint texHeight, SVGColor clearColor, bool fastUpload) { SVGSurface surface; Texture2D texture = null; // create a drawing surface, with the same texture dimensions surface = SVGAssets.CreateSurface(texWidth, texHeight); if (surface == null) { return(null); } // draw the SVG document onto the surface if (surface.Draw(this.m_SvgDoc, clearColor, SVGRenderingQuality.Better)) { // create a 2D texture compatible with the drawing surface texture = surface.CreateCompatibleTexture(true, false); if (texture != null) { texture.hideFlags = HideFlags.HideAndDontSave; // copy the surface content into the texture if (fastUpload && Application.isPlaying) { surface.CopyAndDestroy(texture); } else { if (surface.Copy(texture)) { // call Apply() so it's actually uploaded to the GPU texture.Apply(false, true); } } } } // destroy SVG surface and document surface.Dispose(); // return the created texture return(texture); }
//----- public void FillPolygon(Vector2[] points, SVGColor fillColor, SVGColor? strokeColor, float width) { if((int)width == 1) { FillPolygon(points, strokeColor); return; } SetColor(fillColor.color); FillPolygon(points); if(strokeColor == null)return; SetColor(strokeColor.Value.color); Polygon(points, width); }
//----- public void FillRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor? strokeColor, float width) { if((int)width == 1) { FillRect(p1, p2, p3, p4, fillColor, strokeColor); return; } SetColor(fillColor.color); FillRect(p1, p2, p3, p4); if(strokeColor == null)return; SetColor(strokeColor.Value.color); Rect(p1, p2, p3, p4, strokeColor, width); }
//----- //Fill khong co Stroke, va ve stroke sau public void FillPath(SVGRadialGradientBrush radialGradientBrush, SVGColor? strokePathColor, float width, SVGGraphicsPath graphicsPath) { this._graphicsFill.FillPath(radialGradientBrush, strokePathColor, graphicsPath); if((int)width == 1) this._graphicsFill.FillPath(radialGradientBrush, strokePathColor, graphicsPath); else this._graphicsFill.FillPath(radialGradientBrush, graphicsPath); if(strokePathColor == null)return; SetColor(strokePathColor.Value.color); //graphicsPath.RenderPath(this, width, false); }
//----- //Fill khong co Stroke, va ve stroke sau public void FillPath(SVGColor fillColor, SVGColor? strokePathColor, float width, SVGGraphicsPath graphicsPath) { this._graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); if((int)width == 1)this._graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); else this._graphicsFill.FillPath(fillColor, graphicsPath); if(strokePathColor == null)return; SetColor(strokePathColor.Value.color); }
//----- public void FillEllipse(Vector2 p, float rx, float ry, float angle, SVGColor fillColor, SVGColor? strokeColor) { this._graphicsFill.Ellipse(p, rx, ry, angle, fillColor, strokeColor); }
//----- //Fill co Stroke trong do luon public void FillPath(SVGLinearGradientBrush linearGradientBrush, SVGColor? strokePathColor, SVGGraphicsPath graphicsPath) { this._graphicsFill.FillPath(linearGradientBrush, strokePathColor, graphicsPath); }
public void FillEllipse(Vector2 p, float rx, float ry, float angle, SVGColor fillColor, SVGColor?strokeColor) { graphicsFill.Ellipse(p, rx, ry, angle, fillColor, strokeColor); }
public void FillPolygon(Vector2[] points, SVGColor fillColor, SVGColor?strokeColor) { graphicsFill.Polygon(points, fillColor, strokeColor); }
public void Polygon(Vector2[] points, SVGColor fillColor, SVGColor?strokeColor) { SetColor(fillColor.color); PrePolygon(points); EndSubBuffer(strokeColor); }
public void FillPath(SVGColor fillColor, SVGGraphicsPath graphicsPath) { SetColor(fillColor.color); FillPath(graphicsPath); }
public void Ellipse(Vector2 p, float rx, float ry, float angle, SVGColor fillColor, SVGColor?strokeColor) { SetColor(fillColor.color); PreEllipse(p, rx, ry, angle); EndSubBuffer(strokeColor); }
public void Circle(Vector2 p, float r, SVGColor fillColor, SVGColor?strokeColor) { SetColor(fillColor.color); PreCircle(p, r); EndSubBuffer(); }
public void Rect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor?strokeColor) { SetColor(fillColor.color); PreRect(p1, p2, p3, p4); EndSubBuffer(strokeColor); }
//----- public void FillRoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor? strokeColor, float width) { if((int)width == 1) { FillRoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, strokeColor); return; } SetColor(fillColor.color); this._graphicsFill.RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); if(strokeColor == null)return; SetColor(strokeColor.Value.color); RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, strokeColor); }
public void FillCircle(Vector2 p, float r, SVGColor fillColor, SVGColor?strokeColor) { graphicsFill.Circle(p, r, fillColor, strokeColor); }
//----- public void Polygon(Vector2[] points, SVGColor? strokeColor, float width) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Polygon(points, width); }
public void Rect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor? strokeColor) { SetColor(fillColor.color); PreRect(p1, p2, p3, p4); EndSubBuffer(strokeColor); }
//----- public void FillCircle(Vector2 p, float r, SVGColor fillColor, SVGColor? strokeColor, float width) { if((int)width == 1) { FillCircle(p, r, strokeColor); return; } SetColor(fillColor.color); FillCircle(p, r); if(strokeColor == null)return; SetColor(strokeColor.Value.color); Circle(p, r, strokeColor, width); }
//----- public void Rect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor? strokeColor, float width) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Rect(p1, p2, p3, p4, width); }
//----- public void FillEllipse(Vector2 p, float rx, float ry, float angle, SVGColor fillColor, SVGColor? strokeColor, float width) { if((int)width == 1) { FillEllipse(p, rx, ry, angle, strokeColor); return; } SetColor(fillColor.color); FillEllipse(p, rx, ry, angle); if(strokeColor == null)return; SetColor(strokeColor.Value.color); Ellipse(p, rx, ry, angle, width); }
public void FillRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor?strokeColor) { graphicsFill.Rect(p1, p2, p3, p4, fillColor, strokeColor); }
//----- //Fill co Stroke trong do luon public void FillPath(SVGRadialGradientBrush radialGradientBrush, SVGColor? strokePathColor, SVGGraphicsPath graphicsPath) { this._graphicsFill.FillPath(radialGradientBrush, strokePathColor, graphicsPath); }
public SVGStopElement(AttributeList attrList) { string colorString = attrList.GetValue("stop-color"); string offsetString = attrList.GetValue("offset"); string stopOpacity = attrList.GetValue("stop-opacity"); string styleValue = attrList.GetValue("style"); if (styleValue != null) { string[] styleValues = styleValue.Split(';'); for (int i = 0; i < styleValues.Length; i++) { if (styleValues[i].Contains("stop-color")) { colorString = styleValues[i].Split(':')[1]; } else if (styleValues[i].Contains("stop-opacity")) { stopOpacity = styleValues[i].Split(':')[1]; } else if (styleValues[i].Contains("offset")) { offsetString = styleValues[i].Split(':')[1]; } } } if (colorString == null) { colorString = "black"; } if (offsetString == null) { offsetString = "0%"; } _stopColor = new SVGColor(colorString); if (!string.IsNullOrEmpty(stopOpacity)) { if (stopOpacity.EndsWith("%")) { _stopColor.color.a = float.Parse(stopOpacity.TrimEnd(new char[1] { '%' }), System.Globalization.CultureInfo.InvariantCulture) * 0.01f; } else { _stopColor.color.a = float.Parse(stopOpacity, System.Globalization.CultureInfo.InvariantCulture); } } string temp = offsetString.Trim(); if (temp != "") { if (temp.EndsWith("%")) { _offset = float.Parse(temp.TrimEnd(new char[1] { '%' }), System.Globalization.CultureInfo.InvariantCulture); } else { _offset = float.Parse(temp, System.Globalization.CultureInfo.InvariantCulture) * 100; } } // Debug.Log("StopColor: "+_stopColor.color+", offset: "+_offset); }
//----- //Fill co Stroke trong do luon public void FillPath(SVGColor fillColor, SVGColor? strokePathColor, SVGGraphicsPath graphicsPath) { this._graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); }
protected SVGElement(Dictionary <string, string> _attrList) { attrList = _attrList; stroke = null; fillColor = null; strokeColor = null; fillOpacity = 1.0f; strokeOpacity = 1.0f; strokeWidth = 0; hasFill = true; hasStroke = false; visible = true; element_number = SVGGenerals.getElementId(); if (attrList.ContainsKey("id")) { name = attrList["id"]; } else { name = this.ToString() + "-" + element_number; } foreach (KeyValuePair <string, string> attr in attrList) { switch (attr.Key) { case "transform": transformlist = new SVGTransformList(); transformlist.ParseAttributes(attr.Value); break; case "fill": if (String.Compare(attr.Value, "none") == 0) { hasFill = false; } else if (String.Compare(attr.Value, "transparent") == 0) { hasFill = false; } else { hasFill = true; fillColor = new SVGColor(attr.Value); } break; case "opacity": fillOpacity = StringParser.StringAttrFloat(attr.Value); strokeOpacity = fillOpacity; break; case "fill-opacity": fillOpacity = StringParser.StringAttrFloat(attr.Value); break; case "stroke": if (String.Compare(attr.Value, "none") == 0) { hasStroke = false; } else { hasStroke = true; strokeColor = new SVGColor(attr.Value); } break; case "stroke-width": strokeWidth = StringParser.StringAttrFloat(attr.Value); break; case "stroke-opacity": strokeOpacity = StringParser.StringAttrFloat(attr.Value); break; case "display": if (String.Compare(attr.Value, "none") == 0) { visible = false; } else { visible = true; } break; case "style": //ParseStyle(value); Debug.Log("Attributo style no implementado aun:" + attr.Value); break; default: //Debug.Log("Attributo no implementado: " + attr.Key); break; } } if (hasStroke) { stroke = new SVGStroke(strokeColor, strokeWidth, strokeOpacity); } }
//----- public void FillPolygon(Vector2[] points, SVGColor fillColor, SVGColor? strokeColor) { this._graphicsFill.Polygon(points, fillColor, strokeColor); }
public SVGStroke(SVGColor color, float width, float opacity) { _color = color; _width = width; _opacity = opacity; }
//----- public void FillRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, SVGColor fillColor, SVGColor? strokeColor) { this._graphicsFill.Rect(p1, p2, p3, p4, fillColor, strokeColor); }
//----- //Fill khong co Stroke, va ve stroke sau public void DrawPath(SVGGraphicsPath graphicsPath, float width, SVGColor? strokePathColor) { if(strokePathColor == null)return; SetColor(strokePathColor.Value.color); this._graphicsStroke.DrawPath(graphicsPath, width); }
//----- public void FillRoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor? strokeColor) { this._graphicsFill.RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, fillColor, strokeColor); }
//----- public void Ellipse(Vector2 p, float rx, float ry, float angle, SVGColor? strokeColor, float width) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Ellipse(p, rx, ry, angle, width); }
//----- public void Line(Vector2 p1, Vector2 p2, SVGColor? strokeColor, float width) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } Line(p1, p2, width); }
//----- public void FillCircle(Vector2 p, float r, SVGColor fillColor, SVGColor? strokeColor) { this._graphicsFill.Circle(p, r, fillColor, strokeColor); }
public void Circle(Vector2 p, float r, SVGColor? strokeColor) { PreCircle(p, r); EndSubBuffer(strokeColor); }
//Fill co Stroke trong do luon public void FillPath(SVGColor fillColor, SVGColor?strokePathColor, SVGGraphicsPath graphicsPath) { graphicsFill.FillPath(fillColor, strokePathColor, graphicsPath); }
//----- public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor? strokeColor, float width) { if(strokeColor != null) { SetColor(strokeColor.Value.color); } RoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle, width); }
public void Circle(Vector2 p, float r, SVGColor fillColor, SVGColor? strokeColor) { SetColor(fillColor.color); PreCircle(p, r); EndSubBuffer(); }
public void RoundedRect(Vector2 p1, Vector2 p2, Vector2 p3, Vector2 p4, Vector2 p5, Vector2 p6, Vector2 p7, Vector2 p8, float r1, float r2, float angle, SVGColor fillColor, SVGColor? strokeColor) { SetColor(fillColor.color); PreRoundedRect(p1, p2, p3, p4, p5, p6, p7, p8, r1, r2, angle); EndSubBuffer(strokeColor); }
//Fill khong to Stroke public void FillPath(SVGColor fillColor, SVGGraphicsPath graphicsPath) { _graphicsFill.FillPath(fillColor, graphicsPath); }