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 07f29ffc2b27febdf40a2ff11d50769e5d2fc52a Author: DESKTOP-RH4S838\Yishay <[email protected]> AuthorDate: Tue Jul 3 14:50:52 2018 +0300 Added spread filter element. --- .../Graphics/src/main/resources/defaults.css | 1 + .../Graphics/src/main/resources/svg-manifest.xml | 1 + .../org/apache/royale/svg/DropShadowFilter.as | 25 +++- .../org/apache/royale/svg/SpreadFilterElement.as | 139 +++++++++++++++++++++ 4 files changed, 165 insertions(+), 1 deletion(-) diff --git a/frameworks/projects/Graphics/src/main/resources/defaults.css b/frameworks/projects/Graphics/src/main/resources/defaults.css index bca70a2..da97e79 100644 --- a/frameworks/projects/Graphics/src/main/resources/defaults.css +++ b/frameworks/projects/Graphics/src/main/resources/defaults.css @@ -43,4 +43,5 @@ svg|DropShadowFilter ColorMatrixFilterElement: ClassReference("org.apache.royale.svg.ColorMatrixFilterElement"); BlurFilterElement: ClassReference("org.apache.royale.svg.BlurFilterElement"); BlendFilterElement: ClassReference("org.apache.royale.svg.BlendFilterElement"); + SpreadFilterElement: ClassReference("org.apache.royale.svg.SpreadFilterElement"); } \ No newline at end of file diff --git a/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml b/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml index eb25381..d5b906b 100644 --- a/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml +++ b/frameworks/projects/Graphics/src/main/resources/svg-manifest.xml @@ -26,6 +26,7 @@ <component id="Filter" class="org.apache.royale.svg.Filter" /> <component id="OffsetFilterElement" class="org.apache.royale.svg.OffsetFilterElement" /> <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="BlendFilterElement" class="org.apache.royale.svg.BlendFilterElement" /> <component id="MaskBead" class="org.apache.royale.svg.MaskBead" /> 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 79f9fe9..2132ff6 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 @@ -41,6 +41,7 @@ package org.apache.royale.svg private var _green:Number = 0; private var _blue:Number = 0; private var _opacity:Number = 1; + private var _spread:Number = 1; public function DropShadowFilter() { @@ -74,8 +75,12 @@ package org.apache.royale.svg colorMatrix.blue = blue; colorMatrix.opacity = opacity; colorMatrix.colorMatrixResult = "colorMatrixResult"; + var spreadElement:SpreadFilterElement = loadBeadFromValuesManager(SpreadFilterElement, "spreadFilterElement", value) as SpreadFilterElement; + spreadElement.in1 = "colorMatrixResult"; + spreadElement.spreadResult = "spreadResult"; + spreadElement.spread = spread; var blend:BlendFilterElement = loadBeadFromValuesManager(BlendFilterElement, "blendFilterElement", value) as BlendFilterElement; - blend.in2 = "colorMatrixResult"; + blend.in2 = "spreadResult"; value.removeBead(this); } @@ -225,6 +230,24 @@ package org.apache.royale.svg { _opacity = value; } + + /** + * The spread component of the drop shadow. This can be a number between 0 and 255. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public function get spread():Number + { + return _spread; + } + + public function set spread(value:Number):void + { + _spread = value; + } } } diff --git a/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as new file mode 100644 index 0000000..b3a6559 --- /dev/null +++ b/frameworks/projects/Graphics/src/main/royale/org/apache/royale/svg/SpreadFilterElement.as @@ -0,0 +1,139 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.royale.svg +{ + + import org.apache.royale.core.IBead; + import org.apache.royale.core.IRenderedObject; + import org.apache.royale.core.IStrand; + import org.apache.royale.events.IEventDispatcher; + import org.apache.royale.events.Event; + COMPILE::JS + { + import org.apache.royale.graphics.utils.addSvgElementToElement; + } + + /** + * The SpreadFilterElement adjusts the spread of the filter + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public class SpreadFilterElement implements IBead + { + private var _strand:IStrand; + private var _in1:String = "SourceGraphic"; + private var _spread:Number = 1.0; + private var _spreadResult:String = "spreadResult"; + + public function SpreadFilterElement() + { + } + + /** + * @copy org.apache.royale.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public function set strand(value:IStrand):void + { + _strand = value; + (_strand as IEventDispatcher).addEventListener('beadsAdded', onInitComplete); + } + + /** + * @royaleignorecoercion Element + */ + protected function onInitComplete(e:Event):void + { + COMPILE::JS + { + var filter:Element = (_strand.getBeadByType(Filter) as Filter).filterElementWrapper; + var componentTransfer:Element = addSvgElementToElement(filter, "feComponentTransfer") as Element; + var funcA:Element = addSvgElementToElement(componentTransfer, "feFuncA") as Element; + funcA.setAttribute("type", "linear"); + funcA.setAttribute("slope", spread); + componentTransfer.setAttribute("in1", in1); + componentTransfer.setAttribute("result", spreadResult); + } + } + + /** + * The spread value, can be between 0 and 255. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public function get spread():Number + { + return _spread; + } + + public function set spread(value:Number):void + { + _spread = value; + } + + /** + * Where to write the result of this filter. + * This is useful for using the result as a source for another filter element. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public function get spreadResult():String + { + return _spreadResult; + } + + public function set spreadResult(value:String):void + { + _spreadResult = value; + } + + /** + * The source for this filter element + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.3 + */ + public function get in1():String + { + return _in1; + } + + public function set in1(value:String):void + { + _in1 = value; + } + + } +} +
