You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/12/19 01:42:02 UTC
[royale-asjs] branch develop updated: Graphics improvements for JS:
add some additional NaN safety checks,
and the possibility to have a render target that is a child (e.g. 'g' node)
of a parent svg document.
This is an automated email from the ASF dual-hosted git repository.
gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 38d9d64 Graphics improvements for JS: add some additional NaN safety checks, and the possibility to have a render target that is a child (e.g. 'g' node) of a parent svg document.
38d9d64 is described below
commit 38d9d644939197d4140eb68c91283320b3b4b03b
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sat Dec 19 14:41:43 2020 +1300
Graphics improvements for JS: add some additional NaN safety checks, and the possibility to have a render target that is a child (e.g. 'g' node) of a parent svg document.
---
.../royale/org/apache/royale/display/Graphics.as | 24 ++++++++++++++--------
.../org/apache/royale/display/IGraphicsTarget.as | 2 +-
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/Graphics.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/Graphics.as
index 3db73c2..1b8ca39 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/Graphics.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/Graphics.as
@@ -141,9 +141,9 @@ package org.apache.royale.display
}
COMPILE::JS
{
- var svg:SVGElement = graphicsTarget.graphicsRenderTarget;
- while (svg.firstChild) {
- svg.removeChild(svg.firstChild);
+ var renderTarget:SVGElement = this.renderTarget;
+ while (renderTarget.firstChild) {
+ renderTarget.removeChild(renderTarget.firstChild);
}
_defs = null;
defsIdx = 0;
@@ -169,7 +169,7 @@ package org.apache.royale.display
private var _nonZeroFill:Boolean;
private var _defs:SVGDefsElement;
- private function get svg():SVGElement{
+ private function get renderTarget():SVGElement{
return graphicsTarget.graphicsRenderTarget;
}
@@ -179,7 +179,7 @@ package org.apache.royale.display
private function get defs():SVGDefsElement{
if (!_defs) {
_defs = createGraphicsSVG('defs', false) as SVGDefsElement;
- var svgNode:SVGElement = svg;
+ var svgNode:SVGElement = renderTarget.ownerSVGElement ? renderTarget.ownerSVGElement : renderTarget;
if (svgNode.childNodes.length) {
svgNode.insertBefore(_defs, svgNode.childNodes[0]);
} else svgNode.appendChild(_defs);
@@ -223,7 +223,7 @@ package org.apache.royale.display
}
}
else setNoFill(_currentPath);
- svg.appendChild(_currentPath);
+ renderTarget.appendChild(_currentPath);
//apply the current stroke now, spawning stroke paths if necessary as determined by stroke implementation
currentStroke.apply(this, _currentPath);
}
@@ -273,7 +273,7 @@ package org.apache.royale.display
_currentStrokePath.setAttributeNS(null, 'fill', 'none');
currentStroke.apply(this,_currentStrokePath);
getCurrentPath().setAttributeNS(null, 'stroke', 'none');
- svg.appendChild(_currentStrokePath);
+ renderTarget.appendChild(_currentStrokePath);
if (fromPaint) {
_strokePathData = _currentStrokePath.getAttributeNodeNS(null, 'd');
return _currentStrokePath;
@@ -287,7 +287,7 @@ package org.apache.royale.display
_currentStrokePath.setAttributeNS(null, 'd', 'M' + _lastPoint);
_currentStrokePath.setAttributeNS(null, 'fill', 'none');
_strokePathData = _currentStrokePath.getAttributeNodeNS(null, 'd');
- svg.appendChild(_currentStrokePath);
+ renderTarget.appendChild(_currentStrokePath);
_lastPoint = null;
return _currentStrokePath;
}
@@ -606,6 +606,8 @@ package org.apache.royale.display
}
COMPILE::JS
{
+ if (isNaN(x)) x = 0;
+ if (isNaN(y)) y = 0;
var lp:String = x + ' ' + y;
/*if (!_lastStartPoint)*/ _lastStartPoint = lp;
_moveTo = 'M' + lp;
@@ -621,6 +623,8 @@ package org.apache.royale.display
}
COMPILE::JS
{
+ if (isNaN(x)) x = 0;
+ if (isNaN(y)) y = 0;
var lp:String = x + ' ' + y;
if (!_lastStartPoint) _lastStartPoint = '0 0';
appendPathData('L' + lp, lp);
@@ -635,6 +639,10 @@ package org.apache.royale.display
}
COMPILE::JS
{
+ if (isNaN(controlX)) controlX = 0;
+ if (isNaN(controlY)) controlY = 0;
+ if (isNaN(anchorX)) anchorX = 0;
+ if (isNaN(anchorY)) anchorY = 0;
var lp:String = anchorX + ' ' + anchorY;
if (!_lastStartPoint) _lastStartPoint = '0 0';
appendPathData('Q' + controlX + ' ' + controlY + ' ' + lp, lp);
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/IGraphicsTarget.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/IGraphicsTarget.as
index 13f43eb..af573e0 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/IGraphicsTarget.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/display/IGraphicsTarget.as
@@ -33,7 +33,7 @@ package org.apache.royale.display
COMPILE::JS
- function get graphicsRenderTarget():SVGSVGElement;
+ function get graphicsRenderTarget():SVGElement;
}