You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by al...@apache.org on 2021/01/21 09:34:30 UTC
[royale-asjs] branch develop updated: Wipe Added
This is an automated email from the ASF dual-hosted git repository.
alinakazi 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 cf4a624 Wipe Added
cf4a624 is described below
commit cf4a624a11d0f179dbf32d619a275c703ce9a6e5
Author: alinakazi <al...@gmail.com>
AuthorDate: Thu Jan 21 14:34:14 2021 +0500
Wipe Added
---
.../src/main/resources/spark-royale-manifest.xml | 1 +
.../src/main/royale/spark/effects/Wipe.as | 160 +++++++++++++++++++++
.../src/main/royale/spark/effects/WipeDirection.as | 83 +++++++++++
.../src/main/royale/spark/effects/WipeDown.pbk | 66 +++++++++
.../src/main/royale/spark/effects/WipeLeft.pbk | 66 +++++++++
.../src/main/royale/spark/effects/WipeRight.pbk | 66 +++++++++
.../src/main/royale/spark/effects/WipeUp.pbk | 66 +++++++++
7 files changed, 508 insertions(+)
diff --git a/frameworks/projects/SparkRoyale/src/main/resources/spark-royale-manifest.xml b/frameworks/projects/SparkRoyale/src/main/resources/spark-royale-manifest.xml
index 069e8bc..5a5260c 100644
--- a/frameworks/projects/SparkRoyale/src/main/resources/spark-royale-manifest.xml
+++ b/frameworks/projects/SparkRoyale/src/main/resources/spark-royale-manifest.xml
@@ -133,6 +133,7 @@
<component id="Resize" class="spark.effects.Resize"/>
<component id="SetAction" class="spark.effects.SetAction"/>
<component id="Power" class="spark.effects.easing.Power"/>
+ <component id="Wipe" class="spark.effects.Wipe"/>
<component id="ColorMatrixFilter" class="spark.filters.ColorMatrixFilter"/>
<component id="DropShadowFilter" class="spark.filters.DropShadowFilter"/>
<component id="GlowFilter" class="spark.filters.GlowFilter"/>
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/Wipe.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/Wipe.as
new file mode 100644
index 0000000..38084cb
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/Wipe.as
@@ -0,0 +1,160 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.effects
+{
+
+import mx.effects.IEffectInstance;
+import spark.effects.Animate;
+import mx.utils.ByteArray;
+
+/**
+ * The Wipe effect performs a bitmap transition effect by running a
+ * directional wipe between the first and second bitmaps.
+ * This wipe exposes the second bitmap over the course of the
+ * animation in a direction indicated by the <code>direction</code>
+ * property.
+ *
+ * <p>A pixel-shader program loaded by the effect
+ * runs the underlying bitmap effect.
+ * If you want to use
+ * a different Wipe behavior, you can specify a custom pixel-shader program.
+ * The pixel-shader program must adhere to the constraints
+ * specified for the <code>shaderByteCode</code>
+ * property of AnimateTransitionShader class, and supply three additional
+ * parameters.
+ * The extra parameters required by the Wipe shader
+ * are:</p>
+ *
+ * <ul>
+ * <li>An int <code>direction</code> parameter,
+ * whose value means the same as the related String property
+ * in the Wipe class.</li>
+ * <li>Two floating point parameters:
+ * <code>imageWidth</code> and <code>imageHeight</code>. </li>
+ * </ul>
+ *
+ * <p>All of these parameters are set on the shader when the effect starts playing,
+ * so the parameters need to exist and do something appropriate in
+ * order for the effect to function correctly.</p>
+ *
+ * @mxml
+ *
+ * <p>The <code><s:Wipe></code> tag
+ * inherits all of the tag attributes of its superclass,
+ * and adds the following tag attributes:</p>
+ *
+ * <pre>
+ * <s:Wipe
+ * <b>Properties</b>
+ * id="ID"
+ * direction="right"
+ * />
+ * </pre>
+ *
+ * @see spark.effects.WipeDirection
+ * @see spark.effects.AnimateTransitionShader
+ * @see spark.effects.AnimateTransitionShader#shaderByteCode
+ *
+ * @includeExample examples/WipeExample.mxml
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+public class Wipe extends Animate
+{
+ public var shaderByteCode:Object;
+
+
+ private static var WipeUpShaderClass:Object = "WipeUp.pbj";
+ private static var wipeUpShaderCode:ByteArray = new WipeUpShaderClass();
+ private static var WipeDownShaderClass:Object = "WipeDown.pbj";
+ private static var wipeDownShaderCode:ByteArray = new WipeDownShaderClass();
+ private static var WipeRightShaderClass:Object = "WipeRight.pbj";
+ private static var wipeRightShaderCode:ByteArray = new WipeRightShaderClass();
+ private static var WipeLeftShaderClass:Object = "WipeLeft.pbj";
+ private static var wipeLeftShaderCode:ByteArray = new WipeLeftShaderClass();
+
+
+ [Inspectable(enumeration="left,right,up,down", defaultValue="right")]
+ /**
+ * The direction that the wipe moves during the animation:
+ * <code>WipeDirection.RIGHT</code>, <code>WipeDirection.LEFT</code>,
+ * <code>WipeDirection.UP</code>, or <code>WipeDirection.DOWN</code>.
+ *
+ * @default WipeDirection.RIGHT
+ *
+ * @see WipeDirection#RIGHT
+ * @see WipeDirection#UP
+ * @see WipeDirection#LEFT
+ * @see WipeDirection#DOWN
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public var direction:String = WipeDirection.RIGHT;
+
+ /**
+ * Constructor.
+ *
+ * @param target The Object to animate with this effect.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public function Wipe(target:Object=null)
+ {
+ super(target);
+ // Note that we do not need a separate WipeInstance; the only
+ // addition that Wipe adds is specifying the Crossfade
+ // Pixel Bender shader, which is done at instance creation time,
+ // according to the value of the direction property.
+ // Everything else needed is in the superclass already.
+ }
+
+ /**
+ * @private
+ */
+ override protected function initInstance(instance:IEffectInstance):void
+ {
+ switch (direction)
+ {
+ case WipeDirection.RIGHT:
+ shaderByteCode = wipeRightShaderCode;
+ break;
+ case WipeDirection.LEFT:
+ shaderByteCode = wipeLeftShaderCode;
+ break;
+ case WipeDirection.UP:
+ shaderByteCode = wipeUpShaderCode;
+ break;
+ case WipeDirection.DOWN:
+ shaderByteCode = wipeDownShaderCode;
+ break;
+ }
+ super.initInstance(instance);
+ }
+
+}
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDirection.as b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDirection.as
new file mode 100644
index 0000000..1e7e014
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDirection.as
@@ -0,0 +1,83 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 spark.effects
+{
+/**
+ * The WipeDirection class defines the values
+ * for the <code>direction</code> property of the Wipe class.
+ *
+ * @see spark.effects.Wipe
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+public class WipeDirection
+{
+ //include "../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class constants
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * Wipe direction that starts at the left and moves right
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public static const RIGHT:String = "right";
+
+ /**
+ * Wipe direction that starts at the bottom and moves up
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public static const UP:String = "up";
+
+ /**
+ * Wipe direction that starts at the right and moves left
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public static const LEFT:String = "left";
+
+ /**
+ * Wipe direction that starts at the top and moves down
+ *
+ * @langversion 3.0
+ * @playerversion Flash 10
+ * @playerversion AIR 1.5
+ * @productversion Royale 0.9.8
+ */
+ public static const DOWN:String = "down";
+}
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDown.pbk b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDown.pbk
new file mode 100644
index 0000000..cf1caad
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeDown.pbk
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+<languageVersion : 1.0;>
+kernel WipeDown
+< namespace : "flex";
+ vendor : "Adobe";
+ version : 1;
+ description : "Wipe down between two images for Flex effects";
+>
+{
+ // first input is unused in AnimateTransitionShader effect
+ input image4 src0;
+ input image4 from;
+ input image4 to;
+ output pixel4 dst;
+
+ parameter float progress<
+ minValue: 0.00;
+ maxValue: 1.00;
+ defaultValue: 0.0;
+ >;
+
+ parameter float width<
+ minValue: 0.0;
+ maxValue: 1024.0;
+ defaultValue: 576.0;
+ >;
+
+ parameter float height<
+ minValue: 0.00;
+ maxValue: 1024.0;
+ defaultValue: 384.0;
+ >;
+
+ void
+ evaluatePixel()
+ {
+ float2 coord = outCoord();
+
+ // Use src0 in a branch we won't reach just to defeat the
+ // optimizer from removing the input parameter
+ if ((height * progress) < coord.y)
+ dst = sampleNearest(from, coord);
+ else if (progress < 100.0)
+ dst = sampleNearest(to, coord);
+ else
+ dst = sampleNearest(src0, coord);
+ // workaround for Flash filter bug that replicates last column/row
+ if (coord.x >= width || coord.y >= height)
+ dst.a = 0.0;
+ }
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeLeft.pbk b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeLeft.pbk
new file mode 100644
index 0000000..c66f10d
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeLeft.pbk
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+<languageVersion : 1.0;>
+kernel WipeLeft
+< namespace : "flex";
+ vendor : "Adobe";
+ version : 1;
+ description : "Wipe left between two images for Flex effects";
+>
+{
+ // first input is unused in AnimateTransitionShader effect
+ input image4 src0;
+ input image4 from;
+ input image4 to;
+ output pixel4 dst;
+
+ parameter float progress<
+ minValue: 0.00;
+ maxValue: 1.00;
+ defaultValue: 0.0;
+ >;
+
+ parameter float width<
+ minValue: 0.0;
+ maxValue: 1024.0;
+ defaultValue: 576.0;
+ >;
+
+ parameter float height<
+ minValue: 0.00;
+ maxValue: 1024.0;
+ defaultValue: 384.0;
+ >;
+
+ void
+ evaluatePixel()
+ {
+ float2 coord = outCoord();
+
+ // Use src0 in a branch we won't reach just to defeat the
+ // optimizer from removing the input parameter
+ if ((width * (1.0 - progress)) >= coord.x)
+ dst = sampleNearest(from, coord);
+ else if (progress < 100.0)
+ dst = sampleNearest(to, coord);
+ else
+ dst = sampleNearest(src0, coord);
+ // workaround for Flash filter bug that replicates last column/row
+ if (coord.x >= width || coord.y >= height)
+ dst.a = 0.0;
+ }
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeRight.pbk b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeRight.pbk
new file mode 100644
index 0000000..382efac
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeRight.pbk
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+<languageVersion : 1.0;>
+kernel WipeRight
+< namespace : "flex";
+ vendor : "Adobe";
+ version : 1;
+ description : "Wipe right between two images for Flex effects";
+>
+{
+ // first input is unused in AnimateTransitionShader effect
+ input image4 src0;
+ input image4 from;
+ input image4 to;
+ output pixel4 dst;
+
+ parameter float progress<
+ minValue: 0.00;
+ maxValue: 1.00;
+ defaultValue: 0.0;
+ >;
+
+ parameter float width<
+ minValue: 0.0;
+ maxValue: 1024.0;
+ defaultValue: 576.0;
+ >;
+
+ parameter float height<
+ minValue: 0.00;
+ maxValue: 1024.0;
+ defaultValue: 384.0;
+ >;
+
+ void
+ evaluatePixel()
+ {
+ float2 coord = outCoord();
+
+ // Use src0 in a branch we won't reach just to defeat the
+ // optimizer from removing the input parameter
+ if ((width * progress) < coord.x)
+ dst = sampleNearest(from, coord);
+ else if (progress < 100.0)
+ dst = sampleNearest(to, coord);
+ else
+ dst = sampleNearest(src0, coord);
+ // workaround for Flash filter bug that replicates last column/row
+ if (coord.x >= width || coord.y >= height)
+ dst.a = 0.0;
+ }
+}
diff --git a/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeUp.pbk b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeUp.pbk
new file mode 100644
index 0000000..89f2bd0
--- /dev/null
+++ b/frameworks/projects/SparkRoyale/src/main/royale/spark/effects/WipeUp.pbk
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+<languageVersion : 1.0;>
+kernel WipeUp
+< namespace : "flex";
+ vendor : "Adobe";
+ version : 1;
+ description : "Wipe up between two images for Flex effects";
+>
+{
+ // first input is unused in AnimateTransitionShader effect
+ input image4 src0;
+ input image4 from;
+ input image4 to;
+ output pixel4 dst;
+
+ parameter float progress<
+ minValue: 0.00;
+ maxValue: 1.00;
+ defaultValue: 0.0;
+ >;
+
+ parameter float width<
+ minValue: 0.0;
+ maxValue: 1024.0;
+ defaultValue: 576.0;
+ >;
+
+ parameter float height<
+ minValue: 0.00;
+ maxValue: 1024.0;
+ defaultValue: 384.0;
+ >;
+
+ void
+ evaluatePixel()
+ {
+ float2 coord = outCoord();
+
+ // Use src0 in a branch we won't reach just to defeat the
+ // optimizer from removing the input parameter
+ if ((height * (1.0 - progress)) >= coord.y)
+ dst = sampleNearest(from, coord);
+ else if (progress < 100.0)
+ dst = sampleNearest(to, coord);
+ else
+ dst = sampleNearest(src0, coord);
+ // workaround for Flash filter bug that replicates last column/row
+ if (coord.x >= width || coord.y >= height)
+ dst.a = 0.0;
+ }
+}