royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [royale-asjs] 03/04: handle lines vs files properly
Date Thu, 01 Nov 2018 21:50:17 GMT
This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit b97190c51f3cd2111c5d7ece491f08c9a289ddb7
Author: Alex Harui <aharui@apache.org>
AuthorDate: Thu Nov 1 14:48:23 2018 -0700

    handle lines vs files properly
---
 .../src/main/royale/mx/display/Graphics.as         | 29 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/display/Graphics.as b/frameworks/projects/MXRoyale/src/main/royale/mx/display/Graphics.as
index 06cbf85..74c2729 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/display/Graphics.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/display/Graphics.as
@@ -45,11 +45,14 @@ package mx.display
         COMPILE::JS
         private var svg:HTMLElement;
         
+        private var fillInProgress:Boolean;
+        
         /**
          * @royaleignorecoercion HTMLElement
          */
         public function clear():void
         {
+            fillInProgress = false;
             COMPILE::SWF
             {
                 displayObject.graphics.clear();
@@ -59,6 +62,8 @@ package mx.display
                 if (svg)
                     element.removeChild(svg);
                 svg = document.createElementNS("http://www.w3.org/2000/svg", "svg") as HTMLElement;
+                svg.setAttribute("width", displayObject.width.toString() + "px");
+                svg.setAttribute("height", displayObject.height.toString() + "px");
                 element.appendChild(svg);
             }
         }
@@ -80,6 +85,7 @@ package mx.display
                 fillColor = color;
                 fillAlpha = alpha;
             }
+            fillInProgress = true;
         }
         
         /**
@@ -113,6 +119,7 @@ package mx.display
                     pathParts = null;
                 }
             }
+            fillInProgress = false;
 		}
 		
         /**
@@ -132,11 +139,15 @@ package mx.display
          */
         public function endStroke(): void
         {
+            // sometimes GraphicsUtilities.PolyLine is called to set a path for a fill
+            // and not just draw a line
+            if (fillInProgress) return;
+            
             COMPILE::JS
             {
                 if (pathParts && pathParts.length)
                 {
-                    var path:SVGElement = document.createElementNS("http://www.w3.org/2000/svg",
"path") as SVGElement;
+                    var path:SVGElement = document.createElementNS("http://www.w3.org/2000/svg",
"polyline") as SVGElement;
                     var colorString:String = "RGB(" + (color >> 16) + "," + ((color
& 0xff00) >> 8) + "," + (color & 0xff) + ")";
                     path.setAttribute("stroke", colorString);
                     var widthString:String = thickness.toString();
@@ -144,11 +155,21 @@ package mx.display
                     if (alpha != 1)
                         path.setAttribute("stroke-opacity", alpha.toString());
                     //colorString = "RGB(" + (fillColor >> 16) + "," + ((fillColor
& 0xff00) >> 8) + "," + (fillColor & 0xff) + ")";
-                    //path.setAttribute("fill", colorString);
+                    path.setAttribute("fill", "none");
                     //if (fillAlpha != 1)
                     //    path.setAttribute("fill-opacity", fillAlpha.toString());
-                    var pathString:String = pathParts.join(" ");
-                    path.setAttribute("d", pathString);
+                    var pathString:String = "";
+                    var firstOne:Boolean = true;
+                    var n:int = pathParts.length;
+                    for (var i:int = 0;i < n; i++)
+                    {
+                        var part:String = pathParts[i];
+                        if (!firstOne)
+                            pathString += ",";
+                        firstOne = false;
+                        pathString += part.substring(1);
+                    }
+                    path.setAttribute("points", pathString);
                     path.setAttribute("pointer-events", "none");
                     svg.appendChild(path);
                     pathParts = null;


Mime
View raw message