コード例 #1
0
 public CssBoxSvgRoot(Css.BoxSpec spec, RootGraphic rootgfx, SvgElement svgElem)
     : base(spec, rootgfx, Css.CssDisplay.Block)
 {
     SetAsCustomCssBox(this);
     //create svg node 
     this.SvgSpec = svgElem;
     ChangeDisplayType(this, Css.CssDisplay.Block);
 }
コード例 #2
0
ファイル: SvgElements.cs プロジェクト: prepare/HTML-Renderer
 public void AddChild(SvgElement child)
 {
     if (this.children == null)
     {
         this.children = new LinkedList<SvgElement>();
     }
     child.linkedNode = this.children.AddLast(child);
     child.parent = this;
 }
コード例 #3
0
 public static void HitTestCore(SvgElement root, SvgHitChain chain, float x, float y)
 {
     //1. 
     chain.AddHit(root, x, y);
     //2. find hit child
     var child = root.GetFirstNode();
     while (child != null)
     {
         var node = child.Value;
         if (node.HitTestCore(chain, x, y))
         {
             break;
         }
         child = child.Next;
     }
 }
コード例 #4
0
ファイル: SvgHitChain.cs プロジェクト: prepare/HTML-Renderer
 public void AddHit(SvgElement svg, float x, float y)
 {
     svgList.Add(new SvgHitInfo(svg, x, y));
 }
コード例 #5
0
 public SvgHitInfo(SvgElement svg, float x, float y)
 {
     this.svg = svg;
     this.x   = x;
     this.y   = y;
 }
コード例 #6
0
 public void AddHit(SvgElement svg, float x, float y)
 {
     svgList.Add(new SvgHitInfo(svg, x, y));
 }
コード例 #7
0
ファイル: SvgCreator.cs プロジェクト: mirannda/HtmlRenderer
        static void CreateSvgPath(SvgElement parentNode, HtmlElement elem)
        {
            SvgPathSpec spec    = new SvgPathSpec();
            SvgPath     svgPath = new SvgPath(spec, elem);

            parentNode.AddChild(svgPath);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_X:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Y:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Width:
                {
                    spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Height:
                {
                    spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                default:
                {
                    //other attrs
                    switch (attr.Name)
                    {
                    case "d":
                    {
                        //parse vertex commands
                        Svg.Pathing.SvgPathDataParser parser = new Svg.Pathing.SvgPathDataParser();
                        svgPath.Segments = parser.Parse(attr.Value.ToCharArray());
                    }
                    break;
                    }
                }
                break;
                }
            }
        }
コード例 #8
0
ファイル: SvgCreator.cs プロジェクト: mirannda/HtmlRenderer
        static void CreateSvgBoxContent(
            SvgElement parentElement,
            HtmlElement elementNode)
        {
            int j = elementNode.ChildrenCount;

            for (int i = 0; i < j; ++i)
            {
                HtmlElement node = elementNode.GetChildNode(i) as HtmlElement;
                if (node == null)
                {
                    continue;
                }
                switch (node.WellknownElementName)
                {
                case WellKnownDomNodeName.svg_rect:
                {
                    CreateSvgRect(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_circle:
                {
                    //sample circle from
                    //www.svgbasics.com/shapes.html
                    CreateSvgCircle(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_ellipse:
                {
                    CreateSvgEllipse(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_polygon:
                {
                    CreateSvgPolygon(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_polyline:
                {
                    CreateSvgPolyline(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_defs:
                {
                    CreateSvgDefs(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_linearGradient:
                {
                    CreateSvgLinearGradient(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_path:
                {
                    CreateSvgPath(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_image:
                {
                    CreateSvgImage(parentElement, node);
                }
                break;

                case WellKnownDomNodeName.svg_g:
                {
                    CreateSvgGroupElement(parentElement, node);
                }
                break;

                default:
                {
                }
                break;
                }
            }
        }
コード例 #9
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
 static void CreateSvgPolyline(SvgElement parentNode, HtmlElement elem)
 {
     SvgPolylineSpec spec = new SvgPolylineSpec();
     SvgPolyline shape = new SvgPolyline(spec, elem);
     parentNode.AddChild(shape);
     foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
     {
         WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
         switch (wellknownName)
         {
             case WebDom.WellknownName.Svg_Points:
                 {
                     //parse points
                     spec.Points = ParsePointList(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Fill:
                 {
                     spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke:
                 {
                     spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke_Width:
                 {
                     spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Transform:
                 {
                     //TODO: parse svg transform function  
                 }
                 break;
             default:
                 {
                     //other attrs
                 }
                 break;
         }
     }
 }
コード例 #10
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
 static void CreateSvgBoxContent(
   SvgElement parentElement,
   HtmlElement elementNode)
 {
     int j = elementNode.ChildrenCount;
     for (int i = 0; i < j; ++i)
     {
         HtmlElement node = elementNode.GetChildNode(i) as HtmlElement;
         if (node == null)
         {
             continue;
         }
         switch (node.WellknownElementName)
         {
             case WellKnownDomNodeName.svg_rect:
                 {
                     CreateSvgRect(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_circle:
                 {
                     //sample circle from 
                     //www.svgbasics.com/shapes.html
                     CreateSvgCircle(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_ellipse:
                 {
                     CreateSvgEllipse(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_polygon:
                 {
                     CreateSvgPolygon(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_polyline:
                 {
                     CreateSvgPolyline(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_defs:
                 {
                     CreateSvgDefs(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_linearGradient:
                 {
                     CreateSvgLinearGradient(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_path:
                 {
                     CreateSvgPath(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_image:
                 {
                     CreateSvgImage(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_g:
                 {
                     CreateSvgGroupElement(parentElement, node);
                 }
                 break;
             default:
                 {
                 }
                 break;
         }
     }
 }
コード例 #11
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
        static void CreateSvgLinearGradient(SvgElement parentNode, HtmlElement elem)
        {
            //linear gradient definition

            SvgLinearGradient linearGradient = new SvgLinearGradient(elem);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WellknownName.Svg_X1:
                        {
                            linearGradient.X1 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_X2:
                        {
                            linearGradient.X2 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_Y1:
                        {
                            linearGradient.Y1 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_Y2:
                        {
                            linearGradient.Y2 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                }
            }
            //------------------------------------------------------------
            int j = elem.ChildrenCount;
            List<StopColorPoint> stopColorPoints = new List<StopColorPoint>(j);
            for (int i = 0; i < j; ++i)
            {
                HtmlElement node = elem.GetChildNode(i) as HtmlElement;
                if (node == null)
                {
                    continue;
                }
                switch (node.WellknownElementName)
                {
                    case WellKnownDomNodeName.svg_stop:
                        {
                            //stop point
                            StopColorPoint stopPoint = new StopColorPoint();
                            foreach (WebDom.DomAttribute attr in node.GetAttributeIterForward())
                            {
                                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                                switch (wellknownName)
                                {
                                    case WellknownName.Svg_StopColor:
                                        {
                                            stopPoint.StopColor = CssValueParser.GetActualColor(attr.Value);
                                        }
                                        break;
                                    case WellknownName.Svg_Offset:
                                        {
                                            stopPoint.Offset = UserMapUtil.ParseGenericLength(attr.Value);
                                        }
                                        break;
                                }
                            }
                            stopColorPoints.Add(stopPoint);
                        }
                        break;
                }
            }
        }
コード例 #12
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
 static void CreateSvgDefs(SvgElement parentNode, HtmlElement elem)
 {
     //inside single definition
     SvgDefinitionList svgDefList = new SvgDefinitionList(elem);
     parentNode.AddChild(svgDefList);
     CreateSvgBoxContent(svgDefList, elem);
 }
コード例 #13
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
        static void CreateSvgGroupElement(SvgElement parentNode, HtmlElement elem)
        {
            SvgVisualSpec spec = new SvgVisualSpec();
            SvgGroupElement svgGroupElement = new SvgGroupElement(spec, elem);
            parentNode.AddChild(svgGroupElement);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WebDom.WellknownName.Svg_Fill:
                        {
                            spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke:
                        {
                            spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke_Width:
                        {
                            spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    default:
                        {
                            //other attrs
                        }
                        break;
                }
            }

            CreateSvgBoxContent(svgGroupElement, elem);
        }
コード例 #14
0
ファイル: SvgHitChain.cs プロジェクト: prepare/HTML-Renderer
 public SvgHitInfo(SvgElement svg, float x, float y)
 {
     this.svg = svg;
     this.x = x;
     this.y = y;
 }
コード例 #15
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
        static void CreateSvgPath(SvgElement parentNode, HtmlElement elem)
        {
            SvgPathSpec spec = new SvgPathSpec();
            SvgPath svgPath = new SvgPath(spec, elem);
            parentNode.AddChild(svgPath);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WebDom.WellknownName.Svg_X:
                        {
                            spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Y:
                        {
                            spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Width:
                        {
                            spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Height:
                        {
                            spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Fill:
                        {
                            spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke:
                        {
                            spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke_Width:
                        {
                            spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Transform:
                        {
                            //TODO: parse svg transform function   


                        }
                        break;
                    default:
                        {
                            //other attrs
                            switch (attr.Name)
                            {
                                case "d":
                                    {
                                        //parse vertex commands 
                                        Svg.Pathing.SvgPathDataParser parser = new Svg.Pathing.SvgPathDataParser();
                                        svgPath.Segments = parser.Parse(attr.Value.ToCharArray());
                                    }
                                    break;
                            }
                        }
                        break;
                }
            }
        }
コード例 #16
0
ファイル: SvgCreator.cs プロジェクト: mirannda/HtmlRenderer
        static void CreateSvgLinearGradient(SvgElement parentNode, HtmlElement elem)
        {
            //linear gradient definition

            SvgLinearGradient linearGradient = new SvgLinearGradient(elem);

            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WellknownName.Svg_X1:
                {
                    linearGradient.X1 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_X2:
                {
                    linearGradient.X2 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Y1:
                {
                    linearGradient.Y1 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Y2:
                {
                    linearGradient.Y2 = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;
                }
            }
            //------------------------------------------------------------
            int j = elem.ChildrenCount;
            List <StopColorPoint> stopColorPoints = new List <StopColorPoint>(j);

            for (int i = 0; i < j; ++i)
            {
                HtmlElement node = elem.GetChildNode(i) as HtmlElement;
                if (node == null)
                {
                    continue;
                }
                switch (node.WellknownElementName)
                {
                case WellKnownDomNodeName.svg_stop:
                {
                    //stop point
                    StopColorPoint stopPoint = new StopColorPoint();
                    foreach (WebDom.DomAttribute attr in node.GetAttributeIterForward())
                    {
                        WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                        switch (wellknownName)
                        {
                        case WellknownName.Svg_StopColor:
                        {
                            stopPoint.StopColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;

                        case WellknownName.Svg_Offset:
                        {
                            stopPoint.Offset = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                        }
                    }
                    stopColorPoints.Add(stopPoint);
                }
                break;
                }
            }
        }
コード例 #17
0
ファイル: SvgCreator.cs プロジェクト: prepare/HTML-Renderer
 static void CreateSvgImage(SvgElement parentNode, HtmlElement elem)
 {
     SvgImageSpec spec = new SvgImageSpec();
     SvgImage svgImage = new SvgImage(spec, elem);
     parentNode.AddChild(svgImage);
     foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
     {
         WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
         switch (wellknownName)
         {
             case WebDom.WellknownName.Svg_X:
                 {
                     spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Y:
                 {
                     spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Width:
                 {
                     spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Height:
                 {
                     spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Fill:
                 {
                     spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke:
                 {
                     spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke_Width:
                 {
                     spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Transform:
                 {
                     //TODO: parse svg transform function    
                 }
                 break;
             case WellknownName.Href:
                 {
                     //image src***
                     spec.ImageSrc = attr.Value;
                 }
                 break;
             default:
                 {
                 }
                 break;
         }
     }
 }
コード例 #18
0
ファイル: SvgCreator.cs プロジェクト: mirannda/HtmlRenderer
        static void CreateSvgEllipse(SvgElement parentNode, HtmlElement elem)
        {
            SvgEllipseSpec spec  = new SvgEllipseSpec();
            SvgEllipse     shape = new SvgEllipse(spec, elem);

            parentNode.AddChild(shape);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_Cx:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Cy:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Rx:
                {
                    spec.RadiusX = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WellknownName.Svg_Ry:
                {
                    spec.RadiusY = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                default:
                {
                    //other attrs
                }
                break;
                }
            }
        }
コード例 #19
0
 //--------------------------------
 public static object UnsafeGetController(SvgElement elem)
 {
     return(elem.controller);
 }
コード例 #20
0
ファイル: SvgCreator.cs プロジェクト: mirannda/HtmlRenderer
        static void CreateSvgImage(SvgElement parentNode, HtmlElement elem)
        {
            SvgImageSpec spec     = new SvgImageSpec();
            SvgImage     svgImage = new SvgImage(spec, elem);

            parentNode.AddChild(svgImage);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                case WebDom.WellknownName.Svg_X:
                {
                    spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Y:
                {
                    spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Width:
                {
                    spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Height:
                {
                    spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Fill:
                {
                    spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke:
                {
                    spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Stroke_Width:
                {
                    spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                }
                break;

                case WebDom.WellknownName.Svg_Transform:
                {
                    //TODO: parse svg transform function
                }
                break;

                case WellknownName.Href:
                {
                    //image src***
                    spec.ImageSrc = attr.Value;
                }
                break;

                default:
                {
                }
                break;
                }
            }
        }
コード例 #21
0
ファイル: SvgElements.cs プロジェクト: prepare/HTML-Renderer
 //--------------------------------
 public static object UnsafeGetController(SvgElement elem)
 {
     return elem.controller;
 }