royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ha...@apache.org
Subject [royale-asjs] 15/15: Add swf version for DropShadowFilter
Date Mon, 09 Jul 2018 12:58:38 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 90d9f6632d4afb9f8761712e8f0de94d091f1207
Author: DESKTOP-RH4S838\Yishay <yishayjobs@hotmail.com>
AuthorDate: Mon Jul 9 15:06:34 2018 +0300

    Add swf version for DropShadowFilter
---
 .../org/apache/royale/svg/DropShadowFilter.as      | 84 +++++++++++++---------
 1 file changed, 52 insertions(+), 32 deletions(-)

diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/DropShadowFilter.as
b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/DropShadowFilter.as
index dddc808..aa3f06a 100644
--- a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/DropShadowFilter.as
+++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/DropShadowFilter.as
@@ -22,6 +22,11 @@ package org.apache.royale.svg
 	import org.apache.royale.core.IBead;
 	import org.apache.royale.core.IStrand;
 	import org.apache.royale.core.ValuesManager;
+	COMPILE::SWF 
+	{
+		import org.apache.royale.core.IRenderedObject;
+		import flash.filters.DropShadowFilter;
+	}
 
 	/**
 	 *  DropShadowFilter is a bead that injects a series of beads in the correct 
@@ -58,42 +63,57 @@ package org.apache.royale.svg
 		 */		
 		public function set strand(value:IStrand):void
 		{
-			if (!value)
-			{
-				return;
-			}
-			loadBeadFromValuesManager(Filter, "filter", value);
-			if (inset)
+			COMPILE::JS 
 			{
-				loadBeadFromValuesManager(InvertFilterElement, "invertFilterElement", value);
-			}
-			var offset:OffsetFilterElement = loadBeadFromValuesManager(OffsetFilterElement, "offsetFilterElement",
value) as OffsetFilterElement;
-			offset.dx = dx;
-			offset.dy = dy;
-			var blur:BlurFilterElement = loadBeadFromValuesManager(BlurFilterElement, "blurFilterElement",
value) as BlurFilterElement;
-			blur.stdDeviation = stdDeviation;
-			var colorMatrix:ColorMatrixFilterElement = loadBeadFromValuesManager(ColorMatrixFilterElement,
"colorMatrixFilterElement", value) as ColorMatrixFilterElement;
-			colorMatrix.red = red;
-			colorMatrix.green = green;
-			colorMatrix.blue = blue;
-			colorMatrix.opacity = opacity;
-			var spreadElement:SpreadFilterElement = loadBeadFromValuesManager(SpreadFilterElement,
"spreadFilterElement", value) as SpreadFilterElement;
-			if (!inset)
-			{
-				spreadElement.result = "spreadResult";
+				if (!value)
+				{
+					return;
+				}
+				loadBeadFromValuesManager(Filter, "filter", value);
+				if (inset)
+				{
+					loadBeadFromValuesManager(InvertFilterElement, "invertFilterElement", value);
+				}
+				if (!isNaN(dx) && !isNaN(dy) && (dx !=0 || dy !=0))
+				{
+					var offset:OffsetFilterElement = loadBeadFromValuesManager(OffsetFilterElement, "offsetFilterElement",
value) as OffsetFilterElement;
+					offset.dx = dx;
+					offset.dy = dy;
+				}
+				var blur:BlurFilterElement = loadBeadFromValuesManager(BlurFilterElement, "blurFilterElement",
value) as BlurFilterElement;
+				blur.stdDeviation = stdDeviation;
+				var colorMatrix:ColorMatrixFilterElement = loadBeadFromValuesManager(ColorMatrixFilterElement,
"colorMatrixFilterElement", value) as ColorMatrixFilterElement;
+				colorMatrix.red = red;
+				colorMatrix.green = green;
+				colorMatrix.blue = blue;
+				colorMatrix.opacity = opacity;
+				var spreadElement:SpreadFilterElement = loadBeadFromValuesManager(SpreadFilterElement,
"spreadFilterElement", value) as SpreadFilterElement;
+				if (!inset)
+				{
+					spreadElement.result = "spreadResult";
+				}
+				spreadElement.spread = spread;
+				if (inset)
+				{
+					var composite:CompositeFilterElement = loadBeadFromValuesManager(CompositeFilterElement,
"compositeFilterElement", value) as CompositeFilterElement;
+					composite.in2 = "SourceAlpha";
+					composite.operator = "in";
+					composite.result = "compositeResult";
+				}
+				var blend:BlendFilterElement = loadBeadFromValuesManager(BlendFilterElement, "blendFilterElement",
value) as BlendFilterElement;
+				blend.in = inset ? "compositeResult" : "SourceGraphic";
+				blend.in2 = inset ? "SourceGraphic" : "spreadResult";
+				value.removeBead(this);
 			}
-			spreadElement.spread = spread;
-			if (inset)
+			COMPILE::SWF 
 			{
-				var composite:CompositeFilterElement = loadBeadFromValuesManager(CompositeFilterElement,
"compositeFilterElement", value) as CompositeFilterElement;
-				composite.in2 = "SourceAlpha";
-				composite.operator = "in";
-				composite.result = "compositeResult";
+				var distance:Number = Math.sqrt( (dx * dx) + (dy * dy) );
+				var radians:Number = Math.atan2(dy, dx);
+				var angle:Number =  (180/Math.PI) * radians;
+				var color:uint = red|green|blue;
+				var filter:flash.filters.DropShadowFilter = new flash.filters.DropShadowFilter(distance,
angle, color, opacity, stdDeviation, stdDeviation, spread + 1, 1, inset);
+				(value as IRenderedObject).$displayObject.filters = [filter];
 			}
-			var blend:BlendFilterElement = loadBeadFromValuesManager(BlendFilterElement, "blendFilterElement",
value) as BlendFilterElement;
-			blend.in = inset ? "compositeResult" : "SourceGraphic";
-			blend.in2 = inset ? "SourceGraphic" : "spreadResult";
-			value.removeBead(this);
 		}
 
 		private function loadBeadFromValuesManager(classOrInterface:Class, classOrInterfaceName:String,
strand:IStrand):IBead


Mime
View raw message