/***********************************************************************************/
 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"));
 }
        protected void Init()
        {
            _elementList = new List<object>();

            ViewBoxTransform();

            SVGTransform temp = new SVGTransform(_cachedViewBoxTransform);
            SVGTransformList t_currentTransformList = new SVGTransformList(_attrList.GetValue("transform"));
            t_currentTransformList.AppendItem(temp);

            this.currentTransformList = t_currentTransformList;

            if(_rootElement)
            {
                // TODO Clip Paths does not works properly
                /*
                if(!SVGAssetImport.ignoreSVGCanvas)
                {
                    Rect viewport = paintable.viewport;
                    paintable.clipPathList.Add(new List<Vector2>{
                        new Vector2(viewport.x, viewport.y),
                        new Vector2(viewport.x + viewport.width, viewport.y),
                        new Vector2(viewport.x + viewport.width, viewport.y + viewport.height),
                        new Vector2(viewport.x, viewport.y + viewport.height)
                    });
                }
                */
            }

            GetElementList();
        }
Exemple #4
0
        protected void Init()
        {
            _elementList = new List <object>();

            ViewBoxTransform();

            SVGTransform     temp = new SVGTransform(_cachedViewBoxTransform);
            SVGTransformList t_currentTransformList = new SVGTransformList(_attrList.GetValue("transform"));

            t_currentTransformList.AppendItem(temp);

            this.currentTransformList = t_currentTransformList;

            if (_rootElement)
            {
                // TODO Clip Paths does not works properly

                /*
                 * if(!SVGAssetImport.ignoreSVGCanvas)
                 * {
                 *  Rect viewport = paintable.viewport;
                 *  paintable.clipPathList.Add(new List<Vector2>{
                 *      new Vector2(viewport.x, viewport.y),
                 *      new Vector2(viewport.x + viewport.width, viewport.y),
                 *      new Vector2(viewport.x + viewport.width, viewport.y + viewport.height),
                 *      new Vector2(viewport.x, viewport.y + viewport.height)
                 *  });
                 * }
                 */
            }

            GetElementList();
        }
Exemple #5
0
 protected SVGBasicElement(Dictionary <string, string> attrList,
                           SVGTransformList inheritTransformList,
                           SVGPaintable inheritPaintable,
                           SVGGraphics render) : base(inheritTransformList)
 {
     _render    = render;
     _paintable = new SVGPaintable(inheritPaintable, attrList);
 }
Exemple #6
0
 /***********************************************************************************/
 public void BeforeRender(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
     for(int i = 0; i < _elementList.Count; i++) {
       ISVGDrawable temp = _elementList[i] as ISVGDrawable;
       if(temp != null) temp.BeforeRender(summaryTransformList);
     }
 }
Exemple #7
0
 public SVGGraphicsPath()
 {
     beginPoint        = new Vector2(0f, 0f);
     needSetFirstPoint = true;
     boundUL           = new Vector2(+10000f, +10000f);
     boundBR           = new Vector2(-10000f, -10000f);
     transformList     = new SVGTransformList();
 }
Exemple #8
0
 /***********************************************************************************/
 public SVGPathElement(AttributeList attrList, SVGTransformList inheritTransformList, SVGPaintable inheritPaintable, SVGGraphics r)
     : base(inheritTransformList)
 {
     _attrList = attrList;
     _paintable = new SVGPaintable(inheritPaintable, attrList);
     _render = r;
     Initial();
 }
Exemple #9
0
 public SVGGraphicsPath()
 {
     beginPoint = new Vector2(0f, 0f);
     needSetFirstPoint = true;
     boundUL = new Vector2(+10000f, +10000f);
     boundBR = new Vector2(-10000f, -10000f);
     transformList = new SVGTransformList();
 }
Exemple #10
0
    public SVGPolylineElement(Dictionary<string,string> attrList,
		SVGTransformList inheritTransformList,
		SVGPaintable inheritPaintable,
		SVGGraphics render)
        : base(attrList, inheritTransformList, inheritPaintable, render)
    {
        _listPoints = ExtractPoints(attrList.GetValue("points"));
    }
Exemple #11
0
 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"));
 }
Exemple #12
0
 protected SVGBasicElement(Dictionary<string, string> attrList,
                       SVGTransformList inheritTransformList,
                       SVGPaintable inheritPaintable,
                       SVGGraphics render)
     : base(inheritTransformList)
 {
     _render = render;
       _paintable = new SVGPaintable(inheritPaintable, attrList);
 }
Exemple #13
0
    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"));
    }
Exemple #14
0
 //================================================================================
 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 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"));
 }
Exemple #16
0
 public SVGGraphicsPath()
 {
     beginPoint = new SVGPoint(0f, 0f);
     endPoint = new SVGPoint(0f, 0f);
     needSetFirstPoint = true;
     boundUL = new SVGPoint(+10000f, +10000f);
     boundBR = new SVGPoint(-10000f, -10000f);
     transformList = new SVGTransformList();
     listObject = new ArrayList();
     listType = new ArrayList();
 }
Exemple #17
0
 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"));
 }
Exemple #18
0
    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);
    }
Exemple #19
0
 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"));
 }
Exemple #20
0
 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"));
 }
Exemple #21
0
    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);
    }
Exemple #22
0
 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"));
 }
Exemple #23
0
 public void BeforeRender(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
     for (int i = 0; i < _elementList.Count; ++i)
     {
         ISVGDrawable temp = _elementList[i];
         if (temp != null)
         {
             temp.BeforeRender(summaryTransformList);
         }
     }
 }
Exemple #24
0
 //================================================================================
 //Thuc thi Interface Drawable
 public void BeforeRender(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
     for (int i = 0; i < _segList.Count; i++)
     {
         ISVGDrawable temp = _segList.GetItem(i) as ISVGDrawable;
         if (temp != null)
         {
             temp.BeforeRender(summaryTransformList);
         }
     }
 }
 //================================================================================
 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"));
 }
Exemple #26
0
 protected void UpdateSummaryTransformList()
 {
     int c = 0;
     if(_inheritTransformList != null)
       c += _inheritTransformList.Count;
     if(_currentTransformList != null)
       c += _currentTransformList.Count;
     _summaryTransformList = new SVGTransformList(c);
     if(_inheritTransformList != null)
       _summaryTransformList.AppendItems(_inheritTransformList);
     if(_currentTransformList != null)
       _summaryTransformList.AppendItems(_currentTransformList);
 }
Exemple #27
0
    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 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"));
 }
Exemple #29
0
 /***********************************************************************************/
 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"));
 }
Exemple #30
0
 /***********************************************************************************/
 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();
 }
Exemple #31
0
 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"));
 }
Exemple #32
0
 /***********************************************************************************/
 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();
 }
Exemple #34
0
 /***********************************************************************************/
 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"));
 }
Exemple #36
0
 //================================================================================
 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"));
 }
Exemple #37
0
 //================================================================================
 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"));
 }
Exemple #38
0
    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();
        }
Exemple #40
0
    /***********************************************************************************/
    private void Initial()
    {
        //trich cac gia tri cua thuoc tinh VIEWBOX va chua vao trong _viewport
        SetViewBox();
        _elementList = new List <object>();

        //Viewbox transform se lay thuoc tinh VIEWBOX de tao ra 1 transform
        //va transform nay se chua trong _cachedViewBoxTransform
        ViewBoxTransform();

        //Tao currentTransformList va add cai transform dau tien vao, do la cai VIEWBOX.
        SVGTransform     temp = new SVGTransform(_cachedViewBoxTransform);
        SVGTransformList t_currentTransformList = new SVGTransformList();

        t_currentTransformList.AppendItem(temp);

        this.currentTransformList = t_currentTransformList;

        //Get all element between <SVG>...</SVG>
        GetElementList();
    }
Exemple #41
0
        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();
        }
Exemple #42
0
    protected void UpdateSummaryTransformList()
    {
        int c = 0;

        if (_inheritTransformList != null)
        {
            c += _inheritTransformList.Count;
        }
        if (_currentTransformList != null)
        {
            c += _currentTransformList.Count;
        }
        _summaryTransformList = new SVGTransformList(c);
        if (_inheritTransformList != null)
        {
            _summaryTransformList.AppendItems(_inheritTransformList);
        }
        if (_currentTransformList != null)
        {
            _summaryTransformList.AppendItems(_currentTransformList);
        }
    }
Exemple #43
0
    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);
    }
Exemple #44
0
    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);
    }
Exemple #45
0
    /***********************************************************************************/
    private void Initial()
    {
        currentTransformList = new SVGTransformList(_attrList.GetValue("transform"));

        //-----------
        string _d = _attrList.GetValue("d");

        List <char>   _charList  = new List <char>();
        List <string> _valueList = new List <string>();

        SVGStringExtractor.ExtractPathSegList(_d, 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;
            }
        }
    }
Exemple #46
0
 protected SVGTransformable(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
 }
Exemple #47
0
    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 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;
                    }
                }
            }
        }      
 /***********************************************************************************/
 //Thuc thi Interface Drawable
 public void BeforeRender(SVGTransformList transformList)
 {
     this.inheritTransformList = transformList;
 }
Exemple #50
0
    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();
    }
Exemple #51
0
        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;
                }
                }
            }
        }
Exemple #52
0
 public void AppendItems(SVGTransformList newListItem)
 {
     _listTransform.AddRange(newListItem._listTransform);
     _totalMatrix = null;
 }
Exemple #53
0
 protected SVGTransformable(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
 }
Exemple #54
0
    /***********************************************************************************/
    private void Initial()
    {
        currentTransformList = new SVGTransformList(_attrList.GetValue("transform"));
        _segList = new SVGPathSegList();

        //-----------
        string _d = _attrList.GetValue("d");

        List<char> _charList = new List<char>();
        List<string> _valueList = new List<string>();

        SVGStringExtractor.ExtractPathSegList(_d, ref _charList, ref _valueList);
        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;
          }
        }
    }
Exemple #55
0
 //================================================================================
 //Thuc thi Interface Drawable
 public void BeforeRender(SVGTransformList transformList)
 {
     this.inheritTransformList = transformList;
 }
 /*********************************************************************************************/
 public SVGTransformable(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
 }
Exemple #57
0
 public void AppendItems(SVGTransformList newListItem)
 {
     _listTransform.AddRange(newListItem._listTransform);
     _totalMatrix = null;
 }
 /*********************************************************************************************/
 public SVGTransformable(SVGTransformList transformList)
 {
     inheritTransformList = transformList;
 }
    /***********************************************************************************/
    private void Initial()
    {
        //trich cac gia tri cua thuoc tinh VIEWBOX va chua vao trong _viewport
        SetViewBox();
        _elementList = new List<object>();

        //Viewbox transform se lay thuoc tinh VIEWBOX de tao ra 1 transform
        //va transform nay se chua trong _cachedViewBoxTransform
        ViewBoxTransform();

        //Tao currentTransformList va add cai transform dau tien vao, do la cai VIEWBOX.
        SVGTransform temp = new SVGTransform(_cachedViewBoxTransform);
        SVGTransformList t_currentTransformList = new SVGTransformList();
        t_currentTransformList.AppendItem(temp);

        this.currentTransformList = t_currentTransformList;

        //Get all element between <SVG>...</SVG>
        GetElementList();
    }
Exemple #60
0
    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();
    }