You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2018/07/08 10:16:05 UTC

[royale-asjs] 01/02: Some additions to make inset shadows possible

This is an automated email from the ASF dual-hosted git repository.

yishayw pushed a commit to branch feature/revert-refactor
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 964422693c23c2847a5ca37742f9ab29a2de3ea3
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Wed Jul 4 18:04:48 2018 +0300

    Some additions to make inset shadows possible
---
 .../Graphics/src/main/resources/svg-manifest.xml   |  2 +
 .../org/apache/royale/svg/BlendFilterElement.as    | 12 ++++-
 ...dFilterElement.as => CompositeFilterElement.as} | 61 +++++++++++++++-------
 ...lendFilterElement.as => InvertFilterElement.as} | 34 +++---------
 ...BlendFilterElement.as => MergeFilterElement.as} |  1 -
 .../org/apache/royale/svg/OffsetFilterElement.as   | 12 ++++-
 6 files changed, 75 insertions(+), 47 deletions(-)

diff --git a/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml b/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml
index d5b906b..ed49401 100644
--- a/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml
+++ b/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml
@@ -28,6 +28,8 @@
 	<component id="ColorMatrixFilterElement" class="org.apache.royale.svg.ColorMatrixFilterElement" />
 	<component id="SpreadFilterElement" class="org.apache.royale.svg.SpreadFilterElement" />
 	<component id="BlurFilterElement" class="org.apache.royale.svg.BlurFilterElement" />
+	<component id="InvertFilterElement" class="org.apache.royale.svg.InvertFilterElement" />
+	<component id="CompositeFilterElement" class="org.apache.royale.svg.CompositeFilterElement" />
 	<component id="BlendFilterElement" class="org.apache.royale.svg.BlendFilterElement" />
 	<component id="MaskBead" class="org.apache.royale.svg.MaskBead" />
 	<component id="DisableClipBead" class="org.apache.royale.svg.DisableClipBead" />
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
index 9e46592..bca53eb 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
@@ -40,6 +40,7 @@ package org.apache.royale.svg
 	{
 		private var _strand:IStrand;
 		private var _in2:String;
+		private var _in:String;
 
 		public function BlendFilterElement()
 		{
@@ -68,7 +69,7 @@ package org.apache.royale.svg
 			{
 				var filter:Element = (_strand.getBeadByType(Filter) as Filter).filterElementWrapper;
 				var blend:Element = addSvgElementToElement(filter, "feBlend") as Element;
-				blend.setAttribute("in", "SourceGraphic");
+				blend.setAttribute("in", in);
 				blend.setAttribute("in2", in2);
 				blend.setAttribute("mode", "normal");
 			}
@@ -92,6 +93,15 @@ package org.apache.royale.svg
 			_in2 = value;
 		}
 
+		public function get in():String 
+		{
+			return _in;
+		}
+		
+		public function set in(value:String):void 
+		{
+			_in = value;
+		}
 	}
 }
 
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
similarity index 65%
copy from frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
copy to frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
index 9e46592..00da207 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/CompositeFilterElement.as
@@ -29,19 +29,22 @@ package org.apache.royale.svg
 	}
 
 	/**
-	 *  The BlendFilterElement blends several filter elements
+	 *  The CompositeFilterElement takes two objects and applies Porter/Duff operators
 	 *  
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.9.3
 	 */
-	public class BlendFilterElement implements IBead
+	public class CompositeFilterElement implements IBead
 	{
 		private var _strand:IStrand;
+		private var _in:String;
 		private var _in2:String;
+		private var _result:String;
+		private var _operator:String;
 
-		public function BlendFilterElement()
+		public function CompositeFilterElement()
 		{
 		}
 		
@@ -67,31 +70,53 @@ package org.apache.royale.svg
 			COMPILE::JS 
 			{
 				var filter:Element = (_strand.getBeadByType(Filter) as Filter).filterElementWrapper;
-				var blend:Element = addSvgElementToElement(filter, "feBlend") as Element;
-				blend.setAttribute("in", "SourceGraphic");
-				blend.setAttribute("in2", in2);
-				blend.setAttribute("mode", "normal");
+				var compositeElement:Element = addSvgElementToElement(filter, "feComposite") as Element;
+				compositeElement.setAttribute("in", in);
+				compositeElement.setAttribute("in2", in2);
+				compositeElement.setAttribute("result", result);
+				compositeElement.setAttribute("operator", operator);
 			}
 		}
 
-		/**
-		 *  The filter element result which is blended with the source graphic.
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.9.3
-		 */
-		public function get in2():String
+		public function get in():String 
 		{
-			return _in2;
+			return _in;
+		}
+		
+		public function set in(value:String):void 
+		{
+			_in = value;
 		}
 
-		public function set in2(value:String):void
+		public function get in2():String 
+		{
+			return _in2;
+		}
+		
+		public function set in2(value:String):void 
 		{
 			_in2 = value;
 		}
 
+		public function get operator():String 
+		{
+			return _operator;
+		}
+		
+		public function set operator(value:String):void 
+		{
+			_operator = value;
+		}
+
+		public function get result():String 
+		{
+			return _result;
+		}
+		
+		public function set result(value:String):void 
+		{
+			_result = value;
+		}
 	}
 }
 
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
similarity index 73%
copy from frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
copy to frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
index 9e46592..a2cd104 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/InvertFilterElement.as
@@ -29,19 +29,18 @@ package org.apache.royale.svg
 	}
 
 	/**
-	 *  The BlendFilterElement blends several filter elements
+	 *  The InvertFilterElement makes a filter inset
 	 *  
 	 *  @langversion 3.0
 	 *  @playerversion Flash 10.2
 	 *  @playerversion AIR 2.6
 	 *  @productversion Royale 0.9.3
 	 */
-	public class BlendFilterElement implements IBead
+	public class InvertFilterElement implements IBead
 	{
 		private var _strand:IStrand;
-		private var _in2:String;
 
-		public function BlendFilterElement()
+		public function InvertFilterElement()
 		{
 		}
 		
@@ -67,31 +66,14 @@ package org.apache.royale.svg
 			COMPILE::JS 
 			{
 				var filter:Element = (_strand.getBeadByType(Filter) as Filter).filterElementWrapper;
-				var blend:Element = addSvgElementToElement(filter, "feBlend") as Element;
-				blend.setAttribute("in", "SourceGraphic");
-				blend.setAttribute("in2", in2);
-				blend.setAttribute("mode", "normal");
+				var componentTransfer:Element = addSvgElementToElement(filter, "feComponentTransfer") as Element;
+				componentTransfer.setAttribute("in", "SourceAlpha");
+				var funcA:Element = addSvgElementToElement(componentTransfer, "feFuncA") as Element;
+				funcA.setAttribute("type", "table");
+				funcA.setAttribute("tableValues", "1 0");
 			}
 		}
 
-		/**
-		 *  The filter element result which is blended with the source graphic.
-		 *
-		 *  @langversion 3.0
-		 *  @playerversion Flash 10.2
-		 *  @playerversion AIR 2.6
-		 *  @productversion Royale 0.9.3
-		 */
-		public function get in2():String
-		{
-			return _in2;
-		}
-
-		public function set in2(value:String):void
-		{
-			_in2 = value;
-		}
-
 	}
 }
 
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as
similarity index 99%
copy from frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
copy to frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as
index 9e46592..655242c 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/BlendFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/MergeFilterElement.as
@@ -91,7 +91,6 @@ package org.apache.royale.svg
 		{
 			_in2 = value;
 		}
-
 	}
 }
 
diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
index f2a57a7..7f4d9b6 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/OffsetFilterElement.as
@@ -42,6 +42,7 @@ package org.apache.royale.svg
 		private var _strand:IStrand;
 		private var _dx:Number = 0;
 		private var _dy:Number = 0;
+		private var _in:String;
 		private var _offsetResult:String = "offsetResult";
 
 		public function OffsetFilterElement()
@@ -73,7 +74,7 @@ package org.apache.royale.svg
 				var offset:Element = addSvgElementToElement(filter, "feOffset") as Element;
 				offset.setAttribute("dx", dx);
 				offset.setAttribute("dy", dy);
-				offset.setAttribute("in", "SourceAlpha");
+//				offset.setAttribute("in", in);
 				offset.setAttribute("result", offsetResult);
 			}
 		}
@@ -133,6 +134,15 @@ package org.apache.royale.svg
 			_offsetResult = value;
 		}
 
+		public function get in():String  
+		{
+			return _in;
+		}
+		
+		public function set in(value:String ):void 
+		{
+			_in = value;
+		}
 	}
 }