public SVGPaintable(SVGPaintable inheritPaintable, Dictionary<string, string> attrList) { _linearGradList = inheritPaintable.linearGradList; _radialGradList = inheritPaintable.radialGradList; Initialize(attrList); if(IsFillX() == false) { if(inheritPaintable.IsLinearGradiantFill()) _gradientID = inheritPaintable.gradientID; else if(inheritPaintable.IsRadialGradiantFill()) _gradientID = inheritPaintable.gradientID; else _fillColor = inheritPaintable.fillColor; } if(!IsStroke() && inheritPaintable.IsStroke()) _strokeColor = inheritPaintable.strokeColor; if(_strokeLineCap == SVGStrokeLineCapMethod.Unknown) _strokeLineCap = inheritPaintable.strokeLineCap; if(_strokeLineJoin == SVGStrokeLineJoinMethod.Unknown) _strokeLineJoin = inheritPaintable.strokeLineJoin; if(isStrokeWidth == false) _strokeWidth.NewValueSpecifiedUnits(inheritPaintable.strokeWidth); }
/***********************************************************************************/ public SVGPathElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { _attrList = attrList; _paintable = new SVGPaintable(inheritPaintable, attrList); _render = r; Initial(); }
public SVGPolylineElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _listPoints = ExtractPoints(attrList.GetValue("points")); }
public SVGPaintable(SVGPaintable inheritPaintable, AttributeList attrList) { this._linearGradList = inheritPaintable.linearGradList; this._radialGradList = inheritPaintable.radialGradList;; Initialize(attrList); if(IsFillX() == false) { if(inheritPaintable.IsLinearGradiantFill()) { this._gradientID = inheritPaintable.gradientID; } else if(inheritPaintable.IsRadialGradiantFill()) { this._gradientID = inheritPaintable.gradientID; } else this._fillColor = inheritPaintable.fillColor; } if(!IsStroke()&& inheritPaintable.IsStroke()) { this._strokeColor = inheritPaintable.strokeColor; } if(_strokeLineCap == SVGStrokeLineCapMethod.Unknown) { _strokeLineCap = inheritPaintable.strokeLineCap; } if(_strokeLineJoin == SVGStrokeLineJoinMethod.Unknown) { _strokeLineJoin = inheritPaintable.strokeLineJoin; } if(isStrokeWidth == false) this._strokeWidth.NewValueSpecifiedUnits(inheritPaintable.strokeWidth); }
protected SVGBasicElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; _paintable = new SVGPaintable(inheritPaintable, attrList); }
public SVGPolylineElement(Dictionary<string,string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _listPoints = ExtractPoints(attrList.GetValue("points")); }
public SVGCircleElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _cx = new SVGLength(attrList.GetValue("cx")); _cy = new SVGLength(attrList.GetValue("cy")); _r = new SVGLength(attrList.GetValue("r")); }
protected SVGBasicElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; _paintable = new SVGPaintable(inheritPaintable, attrList); }
//================================================================================ public SVGPolygonElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._render = _render; this._paintable = new SVGPaintable(inheritPaintable, attrList); this._listPoints = ExtractPoints(this._attrList.GetValue("points")); }
public SVGCircleElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _cx = new SVGLength(attrList.GetValue("cx")); _cy = new SVGLength(attrList.GetValue("cy")); _r = new SVGLength(attrList.GetValue("r")); }
//================================================================================ public SVGPolylineElement( AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._render = _render; this._paintable = new SVGPaintable(inheritPaintable, attrList); this._listPoints = ExtractPoints(this._attrList.GetValue("points")); }
public SVGEllipseElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _cx = new SVGLength(attrList.GetValue("cx")); _cy = new SVGLength(attrList.GetValue("cy")); _rx = new SVGLength(attrList.GetValue("rx")); _ry = new SVGLength(attrList.GetValue("ry")); currentTransformList = new SVGTransformList(attrList.GetValue("transform")); }
public SVGLineElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _paintable = new SVGPaintable(inheritPaintable, attrList); _render = render; _x1 = new SVGLength(attrList.GetValue("x1")); _y1 = new SVGLength(attrList.GetValue("y1")); _x2 = new SVGLength(attrList.GetValue("x2")); _y2 = new SVGLength(attrList.GetValue("y2")); }
public SVGRectElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _x = new SVGLength(attrList.GetValue("x")); _y = new SVGLength(attrList.GetValue("y")); _width = new SVGLength(attrList.GetValue("width")); _height = new SVGLength(attrList.GetValue("height")); _rx = new SVGLength(attrList.GetValue("rx")); _ry = new SVGLength(attrList.GetValue("ry")); }
public SVGGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; Dictionary<string, string> attrList = xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, attrList); currentTransformList = new SVGTransformList(attrList.GetValue("transform")); xmlImp.GetElementList(_elementList, _paintable, _render, summaryTransformList); }
public SVGGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; Dictionary <string, string> attrList = xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, attrList); currentTransformList = new SVGTransformList(attrList.GetValue("transform")); xmlImp.GetElementList(_elementList, _paintable, _render, summaryTransformList); }
public SVGEllipseElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _cx = new SVGLength(attrList.GetValue("cx")); _cy = new SVGLength(attrList.GetValue("cy")); _rx = new SVGLength(attrList.GetValue("rx")); _ry = new SVGLength(attrList.GetValue("ry")); currentTransformList = new SVGTransformList(attrList.GetValue("transform")); }
//================================================================================ public SVGCircleElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._render = _render; this._paintable = new SVGPaintable(inheritPaintable, this._attrList); this._cx = new SVGLength(attrList.GetValue("cx")); this._cy = new SVGLength(attrList.GetValue("cy")); this._r = new SVGLength(attrList.GetValue("r")); }
public SVGLineElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _paintable = new SVGPaintable(inheritPaintable, attrList); _render = render; _x1 = new SVGLength(attrList.GetValue("x1")); _y1 = new SVGLength(attrList.GetValue("y1")); _x2 = new SVGLength(attrList.GetValue("x2")); _y2 = new SVGLength(attrList.GetValue("y2")); }
/***********************************************************************************/ public SVGLineElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._paintable = new SVGPaintable(inheritPaintable, this._attrList); this._render = _render; this._x1 = new SVGLength(attrList.GetValue("x1")); this._y1 = new SVGLength(attrList.GetValue("y1")); this._x2 = new SVGLength(attrList.GetValue("x2")); this._y2 = new SVGLength(attrList.GetValue("y2")); }
public SVGRectElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(attrList, inheritTransformList, inheritPaintable, render) { _x = new SVGLength(attrList.GetValue("x")); _y = new SVGLength(attrList.GetValue("y")); _width = new SVGLength(attrList.GetValue("width")); _height = new SVGLength(attrList.GetValue("height")); _rx = new SVGLength(attrList.GetValue("rx")); _ry = new SVGLength(attrList.GetValue("ry")); }
/***********************************************************************************/ public SVGSVGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { _render = r; _xmlImp = xmlImp; _attrList = _xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, _attrList); _width = new SVGLength(_attrList.GetValue("width")); _height = new SVGLength(_attrList.GetValue("height")); Initial(); }
/***********************************************************************************/ public SVGGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; _xmlImp = xmlImp; _attrList = _xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, _attrList); _elementList = new List <object>(); currentTransformList = new SVGTransformList(_attrList.GetValue("transform")); GetElementList(); }
/***********************************************************************************/ public SVGLineElement( AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._paintable = new SVGPaintable(inheritPaintable, this._attrList); this._render = _render; this._x1 = new SVGLength(attrList.GetValue("x1")); this._y1 = new SVGLength(attrList.GetValue("y1")); this._x2 = new SVGLength(attrList.GetValue("x2")); this._y2 = new SVGLength(attrList.GetValue("y2")); }
/***********************************************************************************/ public SVGGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics render) : base(inheritTransformList) { _render = render; _xmlImp = xmlImp; _attrList = _xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, _attrList); _elementList = new List<object>(); currentTransformList = new SVGTransformList(_attrList.GetValue("transform")); GetElementList(); }
/***********************************************************************************/ public SVGSVGElement( SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { _render = r; _xmlImp = xmlImp; _attrList = _xmlImp.Node.Attributes; _paintable = new SVGPaintable(inheritPaintable, _attrList); _width = new SVGLength(_attrList.GetValue("width")); _height = new SVGLength(_attrList.GetValue("height")); Initial(); }
//================================================================================ public SVGRectElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics _render) : base(inheritTransformList) { this._attrList = attrList; this._render = _render; this._paintable = new SVGPaintable(inheritPaintable, this._attrList); this._x = new SVGLength(attrList.GetValue("x")); this._y = new SVGLength(attrList.GetValue("y")); this._width = new SVGLength(attrList.GetValue("width")); this._height = new SVGLength(attrList.GetValue("height")); this._rx = new SVGLength(attrList.GetValue("rx")); this._ry = new SVGLength(attrList.GetValue("ry")); }
public void GetElementList(List <ISVGDrawable> elementList, SVGPaintable paintable, SVGGraphics render, SVGTransformList summaryTransformList) { bool exitFlag = false; while (!exitFlag && Next()) { if (Node is BlockCloseNode) { exitFlag = true; continue; } switch (Node.Name) { case SVGNodeName.Rect: elementList.Add(new SVGRectElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Line: elementList.Add(new SVGLineElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Circle: elementList.Add(new SVGCircleElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Ellipse: elementList.Add(new SVGEllipseElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.PolyLine: elementList.Add(new SVGPolylineElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Polygon: elementList.Add(new SVGPolygonElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Path: elementList.Add(new SVGPathElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.SVG: elementList.Add(new SVGSVGElement(this, summaryTransformList, paintable, render)); break; case SVGNodeName.G: elementList.Add(new SVGGElement(this, summaryTransformList, paintable, render)); break; case SVGNodeName.LinearGradient: paintable.AppendLinearGradient(new SVGLinearGradientElement(this, Node.Attributes)); break; case SVGNodeName.RadialGradient: paintable.AppendRadialGradient(new SVGRadialGradientElement(this, Node.Attributes)); break; case SVGNodeName.Defs: GetElementList(elementList, paintable, render, summaryTransformList); break; case SVGNodeName.Title: GetElementList(elementList, paintable, render, summaryTransformList); break; case SVGNodeName.Desc: GetElementList(elementList, paintable, render, summaryTransformList); break; } } }
public SVGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, bool root = false) : base(inheritTransformList) { _rootElement = root; _name = _attrList.GetValue("id"); _xmlImp = xmlImp; _attrList = _xmlImp.node.attributes; if(inheritPaintable != null) { _paintable = new SVGPaintable(inheritPaintable, _xmlImp.node); } else { _paintable = new SVGPaintable(_xmlImp.node); } Init(); }
public SVGPaintable(SVGPaintable inheritPaintable, Dictionary <string, string> attrList) { _linearGradList = inheritPaintable.linearGradList; _radialGradList = inheritPaintable.radialGradList; Initialize(attrList); if (IsFillX() == false) { if (inheritPaintable.IsLinearGradiantFill()) { _gradientID = inheritPaintable.gradientID; } else if (inheritPaintable.IsRadialGradiantFill()) { _gradientID = inheritPaintable.gradientID; } else { _fillColor = inheritPaintable.fillColor; } } if (!IsStroke() && inheritPaintable.IsStroke()) { _strokeColor = inheritPaintable.strokeColor; } if (_strokeLineCap == SVGStrokeLineCapMethod.Unknown) { _strokeLineCap = inheritPaintable.strokeLineCap; } if (_strokeLineJoin == SVGStrokeLineJoinMethod.Unknown) { _strokeLineJoin = inheritPaintable.strokeLineJoin; } if (isStrokeWidth == false) { _strokeWidth.NewValueSpecifiedUnits(inheritPaintable.strokeWidth); } }
public SVGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, bool root = false) : base(inheritTransformList) { _rootElement = root; _name = _attrList.GetValue("id"); _xmlImp = xmlImp; _attrList = _xmlImp.node.attributes; if (inheritPaintable != null) { _paintable = new SVGPaintable(inheritPaintable, _xmlImp.node); } else { _paintable = new SVGPaintable(_xmlImp.node); } Init(); }
public SVGSVGElement(SVGParser xmlImp, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { _render = r; _attrList = xmlImp.Node.Attributes; var paintable = new SVGPaintable(inheritPaintable, _attrList); _width = new SVGLength(_attrList.GetValue("width")); _height = new SVGLength(_attrList.GetValue("height")); SetViewBox(); ViewBoxTransform(); SVGTransform temp = new SVGTransform(_cachedViewBoxTransform); SVGTransformList t_currentTransformList = new SVGTransformList(); t_currentTransformList.AppendItem(temp); currentTransformList = t_currentTransformList; // use setter only once, since it also updates other lists xmlImp.GetElementList(_elementList, paintable, _render, summaryTransformList); }
public void GetElementList(List<object> elementList, SVGPaintable paintable, SVGTransformList summaryTransformList) { bool exitFlag = false; while (!exitFlag && Next()) { //while (Next()) if (node is BlockCloseNode) { exitFlag = true; continue; } //Debug.Log(node.name); switch (node.name) { case SVGNodeName.Rect: { elementList.Add(new SVGRectElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Line: { elementList.Add(new SVGLineElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Circle: { elementList.Add(new SVGCircleElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Ellipse: { elementList.Add(new SVGEllipseElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.PolyLine: { elementList.Add(new SVGPolylineElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Polygon: { elementList.Add(new SVGPolygonElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Path: { elementList.Add(new SVGPathElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.SVG: { if(node is InlineNode) break; elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } case SVGNodeName.Symbol: { if(node is InlineNode) break; elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } case SVGNodeName.G: { if(node is InlineNode) break; elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } /* case SVGNodeName.ClipPath: { paintable.AppendClipPath(new SVGClipPathElement(this, node)); break; } */ case SVGNodeName.LinearGradient: { ResolveGradientLinks(); paintable.AppendLinearGradient(new SVGLinearGradientElement(this, node)); break; } case SVGNodeName.RadialGradient: { ResolveGradientLinks(); paintable.AppendRadialGradient(new SVGRadialGradientElement(this, node)); break; } case SVGNodeName.ConicalGradient: { ResolveGradientLinks(); paintable.AppendConicalGradient(new SVGConicalGradientElement(this, node)); break; } case SVGNodeName.Defs: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Title: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Desc: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Style: { paintable.AddCSS(node.content); break; } case SVGNodeName.Use: { // Debug.Log("Begin Use Command: " + node.attributes.GetValue("id")); string xlink = node.attributes.GetValue("xlink:href"); if (!string.IsNullOrEmpty(xlink)) { if (xlink [0] == '#') xlink = xlink.Remove(0, 1); if (_defs.ContainsKey(xlink)) { Node definitionNode = _defs [xlink]; if (definitionNode != null && definitionNode != node) { List<Node> injectNodes = definitionNode.GetNodes(); if (injectNodes != null && injectNodes.Count > 0) { nodes [idx] = new BlockOpenNode(SVGNodeName.Use, node.attributes, node.depth); injectNodes.Add(new BlockCloseNode(SVGNodeName.Use, new AttributeList(), node.depth)); nodes.InsertRange(idx + 1, injectNodes); elementList.Add(new SVGElement(this, summaryTransformList, paintable)); } } } } break; } } } }
public void GetElementList(List<ISVGDrawable> elementList, SVGPaintable paintable, SVGGraphics render, SVGTransformList summaryTransformList) { bool exitFlag = false; while(!exitFlag && Next()) { if(Node is BlockCloseNode) { exitFlag = true; continue; } switch(Node.Name) { case SVGNodeName.Rect: elementList.Add(new SVGRectElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Line: elementList.Add(new SVGLineElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Circle: elementList.Add(new SVGCircleElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Ellipse: elementList.Add(new SVGEllipseElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.PolyLine: elementList.Add(new SVGPolylineElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Polygon: elementList.Add(new SVGPolygonElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.Path: elementList.Add(new SVGPathElement(Node.Attributes, summaryTransformList, paintable, render)); break; case SVGNodeName.SVG: elementList.Add(new SVGSVGElement(this, summaryTransformList, paintable, render)); break; case SVGNodeName.G: elementList.Add(new SVGGElement(this, summaryTransformList, paintable, render)); break; case SVGNodeName.LinearGradient: paintable.AppendLinearGradient(new SVGLinearGradientElement(this, Node.Attributes)); break; case SVGNodeName.RadialGradient: paintable.AppendRadialGradient(new SVGRadialGradientElement(this, Node.Attributes)); break; case SVGNodeName.Defs: GetElementList(elementList, paintable, render, summaryTransformList); break; case SVGNodeName.Title: GetElementList(elementList, paintable, render, summaryTransformList); break; case SVGNodeName.Desc: GetElementList(elementList, paintable, render, summaryTransformList); break; } } }
public SVGPathElement(Dictionary <string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { Profiler.BeginSample("SVGPathElement constructor"); _paintable = new SVGPaintable(inheritPaintable, attrList); _render = r; currentTransformList = new SVGTransformList(attrList.GetValue("transform")); string dstr = attrList.GetValue("d"); int nbSegments = 0; for (int i = 0; i < dstr.Length; ++i) { switch (dstr[i]) { case 'Z': case 'z': case 'M': case 'm': case 'L': case 'l': case 'C': case 'c': case 'S': case 's': case 'Q': case 'q': case 'T': case 't': case 'A': case 'a': case 'H': case 'h': case 'V': case 'v': ++nbSegments; break; } } _segList = new SVGPathSegList(nbSegments); // optimization: count number of segments before starting for (int i = 0; i < dstr.Length;) { while (i < dstr.Length - 1 && dstr[i] == ' ') // skip whitespace before type character { ++i; } char _char = dstr[i]; switch (_char) { case 'Z': case 'z': _segList.AppendItem(CreateSVGPathSegClosePath()); ++i; break; case 'M': { try { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegMovetoAbs(a, b)); } catch (Exception) { Debug.Log("exception when parsing " + dstr); throw; } break; } case 'm': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegMovetoRel(a, b)); break; } case 'L': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoAbs(a, b)); break; } case 'l': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoRel(a, b)); break; } case 'C': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); float e = ReadFloat(dstr, ref i); float f = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicAbs(a, b, c, d, e, f)); break; } case 'c': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); float e = ReadFloat(dstr, ref i); float f = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicRel(a, b, c, d, e, f)); break; } case 'S': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothAbs(a, b, c, d)); break; } case 's': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothRel(a, b, c, d)); break; } case 'Q': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticAbs(a, b, c, d)); break; } case 'q': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticRel(a, b, c, d)); break; } case 'T': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothAbs(a, b)); break; } case 't': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothRel(a, b)); break; } case 'A': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); bool d = ReadFloat(dstr, ref i) > 0; bool e = ReadFloat(dstr, ref i) > 0; float f = ReadFloat(dstr, ref i); float g = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegArcAbs(a, b, c, d, e, f, g)); break; } case 'a': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); bool d = ReadFloat(dstr, ref i) > 0; bool e = ReadFloat(dstr, ref i) > 0; float f = ReadFloat(dstr, ref i); float g = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegArcRel(a, b, c, d, e, f, g)); break; } case 'H': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoHorizontalAbs(a)); break; } case 'h': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoHorizontalRel(a)); break; } case 'V': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoVerticalAbs(a)); break; } case 'v': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoVerticalRel(a)); break; } default: ++i; break; } } //List<char> _charList = new List<char>(); //List<string> _valueList = new List<string>(); //SVGStringExtractor.ExtractPathSegList(dstr, ref _charList, ref _valueList); //_segList = new SVGPathSegList(_charList.Count); //for (int i = 0; i < _charList.Count; i++) //{ // char _char = _charList[i]; // string _value = _valueList[i]; // float[] parms = SVGStringExtractor.ExtractTransformValueAsPX(_value); // switch (_char) // { // case 'Z': // case 'z': // _segList.AppendItem(CreateSVGPathSegClosePath()); // break; // case 'M': // _segList.AppendItem(new SVGPathSegMovetoAbs(parms[0], parms[1])); // break; // case 'm': // _segList.AppendItem(new SVGPathSegMovetoRel(parms[0], parms[1])); // break; // case 'L': // _segList.AppendItem(new SVGPathSegLinetoAbs(parms[0], parms[1])); // break; // case 'l': // _segList.AppendItem(new SVGPathSegLinetoRel(parms[0], parms[1])); // break; // case 'C': // _segList.AppendItem(new SVGPathSegCurvetoCubicAbs(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5])); // break; // case 'c': // _segList.AppendItem(new SVGPathSegCurvetoCubicRel(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5])); // break; // case 'S': // _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothAbs(parms[0], parms[1], parms[2], parms[3])); // break; // case 's': // _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothRel(parms[0], parms[1], parms[2], parms[3])); // break; // case 'Q': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticAbs(parms[0], parms[1], parms[2], parms[3])); // break; // case 'q': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticRel(parms[0], parms[1], parms[2], parms[3])); // break; // case 'T': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothAbs(parms[0], parms[1])); // break; // case 't': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothRel(parms[0], parms[1])); // break; // case 'A': // _segList.AppendItem(new SVGPathSegArcAbs(parms[0], parms[1], parms[2], parms[3] == 1f, parms[4] == 1f, parms[5], // parms[6])); // break; // case 'a': // _segList.AppendItem(new SVGPathSegArcRel(parms[0], parms[1], parms[2], parms[3] == 1f, parms[4] == 1f, parms[5], // parms[6])); // break; // case 'H': // _segList.AppendItem(new SVGPathSegLinetoHorizontalAbs(parms[0])); // break; // case 'h': // _segList.AppendItem(new SVGPathSegLinetoHorizontalRel(parms[0])); // break; // case 'V': // _segList.AppendItem(new SVGPathSegLinetoVerticalAbs(parms[0])); // break; // case 'v': // _segList.AppendItem(new SVGPathSegLinetoVerticalRel(parms[0])); // break; // } //} Profiler.EndSample(); }
public void GetElementList(List <object> elementList, SVGPaintable paintable, SVGTransformList summaryTransformList) { bool exitFlag = false; while (!exitFlag && Next()) { //while (Next()) if (node is BlockCloseNode) { exitFlag = true; continue; } //Debug.Log(node.name); switch (node.name) { case SVGNodeName.Rect: { elementList.Add(new SVGRectElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Line: { elementList.Add(new SVGLineElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Circle: { elementList.Add(new SVGCircleElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Ellipse: { elementList.Add(new SVGEllipseElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.PolyLine: { elementList.Add(new SVGPolylineElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Polygon: { elementList.Add(new SVGPolygonElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.Path: { elementList.Add(new SVGPathElement(node, summaryTransformList, paintable)); break; } case SVGNodeName.SVG: { if (node is InlineNode) { break; } elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } case SVGNodeName.Symbol: { if (node is InlineNode) { break; } elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } case SVGNodeName.G: { if (node is InlineNode) { break; } elementList.Add(new SVGElement(this, summaryTransformList, paintable)); break; } /* * case SVGNodeName.ClipPath: * { * paintable.AppendClipPath(new SVGClipPathElement(this, node)); * break; * } */ case SVGNodeName.LinearGradient: { ResolveGradientLinks(); paintable.AppendLinearGradient(new SVGLinearGradientElement(this, node)); break; } case SVGNodeName.RadialGradient: { ResolveGradientLinks(); paintable.AppendRadialGradient(new SVGRadialGradientElement(this, node)); break; } case SVGNodeName.ConicalGradient: { ResolveGradientLinks(); paintable.AppendConicalGradient(new SVGConicalGradientElement(this, node)); break; } case SVGNodeName.Defs: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Title: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Desc: { GetElementList(elementList, paintable, summaryTransformList); break; } case SVGNodeName.Style: { paintable.AddCSS(node.content); break; } case SVGNodeName.Use: { // Debug.Log("Begin Use Command: " + node.attributes.GetValue("id")); string xlink = node.attributes.GetValue("xlink:href"); if (!string.IsNullOrEmpty(xlink)) { if (xlink [0] == '#') { xlink = xlink.Remove(0, 1); } if (_defs.ContainsKey(xlink)) { Node definitionNode = _defs [xlink]; if (definitionNode != null && definitionNode != node) { List <Node> injectNodes = definitionNode.GetNodes(); if (injectNodes != null && injectNodes.Count > 0) { nodes [idx] = new BlockOpenNode(SVGNodeName.Use, node.attributes, node.depth); injectNodes.Add(new BlockCloseNode(SVGNodeName.Use, new AttributeList(), node.depth)); nodes.InsertRange(idx + 1, injectNodes); elementList.Add(new SVGElement(this, summaryTransformList, paintable)); } } } } break; } } } }
public SVGPathElement(Dictionary<string, string> attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r) : base(inheritTransformList) { Profiler.BeginSample("SVGPathElement constructor"); _paintable = new SVGPaintable(inheritPaintable, attrList); _render = r; currentTransformList = new SVGTransformList(attrList.GetValue("transform")); string dstr = attrList.GetValue("d"); int nbSegments = 0; for(int i = 0; i < dstr.Length; ++i) { switch(dstr[i]) { case 'Z': case 'z': case 'M': case 'm': case 'L': case 'l': case 'C': case 'c': case 'S': case 's': case 'Q': case 'q': case 'T': case 't': case 'A': case 'a': case 'H': case 'h': case 'V': case 'v': ++nbSegments; break; } } _segList = new SVGPathSegList(nbSegments); // optimization: count number of segments before starting for(int i = 0; i < dstr.Length;) { while(i < dstr.Length - 1 && dstr[i] == ' ') // skip whitespace before type character ++i; char _char = dstr[i]; switch(_char) { case 'Z': case 'z': _segList.AppendItem(CreateSVGPathSegClosePath()); ++i; break; case 'M': { try { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegMovetoAbs(a, b)); } catch(Exception) { Debug.Log("exception when parsing " + dstr); throw; } break; } case 'm': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegMovetoRel(a, b)); break; } case 'L': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoAbs(a, b)); break; } case 'l': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoRel(a, b)); break; } case 'C': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); float e = ReadFloat(dstr, ref i); float f = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicAbs(a, b, c, d, e, f)); break; } case 'c': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); float e = ReadFloat(dstr, ref i); float f = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicRel(a, b, c, d, e, f)); break; } case 'S': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothAbs(a, b, c, d)); break; } case 's': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothRel(a, b, c, d)); break; } case 'Q': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticAbs(a, b, c, d)); break; } case 'q': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); float d = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticRel(a, b, c, d)); break; } case 'T': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothAbs(a, b)); break; } case 't': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothRel(a, b)); break; } case 'A': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); bool d = ReadFloat(dstr, ref i) > 0; bool e = ReadFloat(dstr, ref i) > 0; float f = ReadFloat(dstr, ref i); float g = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegArcAbs(a, b, c, d, e, f, g)); break; } case 'a': { float a = ReadFloat(dstr, ref i); float b = ReadFloat(dstr, ref i); float c = ReadFloat(dstr, ref i); bool d = ReadFloat(dstr, ref i) > 0; bool e = ReadFloat(dstr, ref i) > 0; float f = ReadFloat(dstr, ref i); float g = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegArcRel(a, b, c, d, e, f, g)); break; } case 'H': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoHorizontalAbs(a)); break; } case 'h': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoHorizontalRel(a)); break; } case 'V': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoVerticalAbs(a)); break; } case 'v': { float a = ReadFloat(dstr, ref i); _segList.AppendItem(new SVGPathSegLinetoVerticalRel(a)); break; } default: ++i; break; } } //List<char> _charList = new List<char>(); //List<string> _valueList = new List<string>(); //SVGStringExtractor.ExtractPathSegList(dstr, ref _charList, ref _valueList); //_segList = new SVGPathSegList(_charList.Count); //for (int i = 0; i < _charList.Count; i++) //{ // char _char = _charList[i]; // string _value = _valueList[i]; // float[] parms = SVGStringExtractor.ExtractTransformValueAsPX(_value); // switch (_char) // { // case 'Z': // case 'z': // _segList.AppendItem(CreateSVGPathSegClosePath()); // break; // case 'M': // _segList.AppendItem(new SVGPathSegMovetoAbs(parms[0], parms[1])); // break; // case 'm': // _segList.AppendItem(new SVGPathSegMovetoRel(parms[0], parms[1])); // break; // case 'L': // _segList.AppendItem(new SVGPathSegLinetoAbs(parms[0], parms[1])); // break; // case 'l': // _segList.AppendItem(new SVGPathSegLinetoRel(parms[0], parms[1])); // break; // case 'C': // _segList.AppendItem(new SVGPathSegCurvetoCubicAbs(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5])); // break; // case 'c': // _segList.AppendItem(new SVGPathSegCurvetoCubicRel(parms[0], parms[1], parms[2], parms[3], parms[4], parms[5])); // break; // case 'S': // _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothAbs(parms[0], parms[1], parms[2], parms[3])); // break; // case 's': // _segList.AppendItem(new SVGPathSegCurvetoCubicSmoothRel(parms[0], parms[1], parms[2], parms[3])); // break; // case 'Q': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticAbs(parms[0], parms[1], parms[2], parms[3])); // break; // case 'q': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticRel(parms[0], parms[1], parms[2], parms[3])); // break; // case 'T': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothAbs(parms[0], parms[1])); // break; // case 't': // _segList.AppendItem(new SVGPathSegCurvetoQuadraticSmoothRel(parms[0], parms[1])); // break; // case 'A': // _segList.AppendItem(new SVGPathSegArcAbs(parms[0], parms[1], parms[2], parms[3] == 1f, parms[4] == 1f, parms[5], // parms[6])); // break; // case 'a': // _segList.AppendItem(new SVGPathSegArcRel(parms[0], parms[1], parms[2], parms[3] == 1f, parms[4] == 1f, parms[5], // parms[6])); // break; // case 'H': // _segList.AppendItem(new SVGPathSegLinetoHorizontalAbs(parms[0])); // break; // case 'h': // _segList.AppendItem(new SVGPathSegLinetoHorizontalRel(parms[0])); // break; // case 'V': // _segList.AppendItem(new SVGPathSegLinetoVerticalAbs(parms[0])); // break; // case 'v': // _segList.AppendItem(new SVGPathSegLinetoVerticalRel(parms[0])); // break; // } //} Profiler.EndSample(); }