public SvgSvgElement(SvgLength x, SvgLength y, SvgLength width, SvgLength height, SvgNumList vport) { X=x; Y=y; Width=width; Height=height; ViewBox=vport; }
public void FromString(string s) { try { float[] array = SvgNumList.String2Floats(s); float[] array2 = array; for (int i = 0; i < array2.Length; i++) { float num = array2[i]; this._pts.Add(num); } } catch (Exception) { throw new SvgException("Invalid SvgNumList", s); } }
/// <summary> /// The standard boils down to a list of numbers in any format separated by any amount of wsp and commas; /// in other words it looks the same as a SvgNumList /// </summary> /// <param name="s"></param> public void FromString(string s) { try { var fa = SvgNumList.String2Floats(s); foreach (float f in fa) { _pts.Add(f); } } catch (Exception) { throw new SvgException("Invalid SvgPoints", s); } if (_pts.Count % 2 != 0) { throw new SvgException("Invalid SvgPoints", s); } }
public SvgPatternElement(SvgLength width, SvgLength height, SvgNumList vport) { Width=width; Height=height; ViewBox=vport; }
public void FromString(string s) { this._m = new Matrix(); int num = s.IndexOf("("); if (num != -1) { string text = s.Substring(0, num).Trim(); int num2 = s.IndexOf(")"); if (num2 != -1) { string s2 = s.Substring(num + 1, num2 - num - 1); float[] array = SvgNumList.String2Floats(s2); if (text.IndexOf("matrix") != -1) { if (array.Length == 6) { this._m = new Matrix(array[0], array[1], array[2], array[3], array[4], array[5]); return; } } else if (text.IndexOf("translate") != -1) { if (array.Length == 1) { this._m.Translate(array[0], 0f); return; } if (array.Length == 2) { this._m.Translate(array[0], array[1]); return; } } else if (text.IndexOf("scale") != -1) { if (array.Length == 1) { this._m.Scale(array[0], 0f); return; } if (array.Length == 2) { this._m.Scale(array[0], array[1]); return; } } else if (text.IndexOf("rotate") != -1) { if (array.Length == 1) { this._m.Rotate(array[0]); return; } if (array.Length == 3) { this._m.Translate(array[1], array[2]); this._m.Rotate(array[0]); this._m.Translate(array[1] * -1f, array[2] * -1f); return; } } else if (text.IndexOf("skewX") != -1) { if (array.Length == 1) { this._m.Shear(array[0], 0f); return; } } else if (text.IndexOf("skewY") != -1) { if (array.Length == 1) { this._m.Shear(0f, array[0]); return; } } } } throw new SvgException("Invalid SvgTransformation", s); }
/// <summary> /// Parse a transformation according to the SVG standard. This is complex enough that it makes /// me wish it was worth using a real parser, but antlr is so unwieldy. /// </summary> public void FromString(string s) { _m = new Matrix(); string name, args; int idx = s.IndexOf("("); if (idx != -1) { name = s.Substring(0, idx).Trim(); int idx2 = s.IndexOf(")"); if (idx2 != -1) { args = s.Substring(idx + 1, (idx2 - idx) - 1); float[] points = SvgNumList.String2Floats(args); if (name.IndexOf("matrix") != -1) { if (points.Length == 6) { _m = new Matrix(points[0], points[1], points[2], points[3], points[4], points[5]); return; } } else if (name.IndexOf("translate") != -1) { if (points.Length == 1) { _m.Translate(points[0], 0); return; } if (points.Length == 2) { _m.Translate(points[0], points[1]); return; } } else if (name.IndexOf("scale") != -1) { if (points.Length == 1) { _m.Scale(points[0], 0); return; } if (points.Length == 2) { _m.Scale(points[0], points[1]); return; } } else if (name.IndexOf("rotate") != -1) { if (points.Length == 1) { _m.Rotate(points[0]); return; } else if (points.Length == 3) { _m.Translate(points[1], points[2]); _m.Rotate(points[0]); _m.Translate(points[1] * -1, points[2] * -1); return; } } else if (name.IndexOf("skewX") != -1) { if (points.Length == 1) { _m.Shear(points[0], 0); return; } } else if (name.IndexOf("skewY") != -1) { if (points.Length == 1) { _m.Shear(0, points[0]); return; } } } } throw new SvgException("Invalid SvgTransformation", s); }