You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by pu...@apache.org on 2020/09/21 17:47:14 UTC
[royale-asjs] branch develop updated: Create Elastic.as
This is an automated email from the ASF dual-hosted git repository.
pushminakazi 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 c7e21af Create Elastic.as
c7e21af is described below
commit c7e21afac3374893e53a2151b544ab58e2b6a293
Author: pashminakazi <42...@users.noreply.github.com>
AuthorDate: Mon Sep 21 22:47:08 2020 +0500
Create Elastic.as
---
.../src/main/royale/mx/effects/easing/Elastic.as | 206 +++++++++++++++++++++
1 file changed, 206 insertions(+)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/effects/easing/Elastic.as b/frameworks/projects/MXRoyale/src/main/royale/mx/effects/easing/Elastic.as
new file mode 100644
index 0000000..2c006b6
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/effects/easing/Elastic.as
@@ -0,0 +1,206 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// 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 mx.effects.easing
+{
+
+/**
+ * The Elastc class defines three easing functions to implement
+ * motion with Flex effect classes, where the motion is defined by
+ * an exponentially decaying sine wave.
+ *
+ * For more information, see http://www.robertpenner.com/profmx.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+public class Elastic
+{
+ //include "../../core/Version.as";
+
+ //--------------------------------------------------------------------------
+ //
+ // Class methods
+ //
+ //--------------------------------------------------------------------------
+
+ /**
+ * The <code>easeIn()</code> method starts motion slowly,
+ * and then accelerates motion as it executes.
+ *
+ * @param t Specifies time.
+ *
+ * @param b Specifies the initial position of a component.
+ *
+ * @param c Specifies the total change in position of the component.
+ *
+ * @param d Specifies the duration of the effect, in milliseconds.
+ *
+ * @param a Specifies the amplitude of the sine wave.
+ *
+ * @param p Specifies the period of the sine wave.
+ *
+ * @return Number corresponding to the position of the component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function easeIn(t:Number, b:Number,
+ c:Number, d:Number,
+ a:Number = 0, p:Number = 0):Number
+ {
+ if (t == 0)
+ return b;
+
+ if ((t /= d) == 1)
+ return b + c;
+
+ if (!p)
+ p = d * 0.3;
+
+ var s:Number;
+ if (!a || a < Math.abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ {
+ s = p / (2 * Math.PI) * Math.asin(c / a);
+ }
+
+ return -(a * Math.pow(2, 10 * (t -= 1)) *
+ Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
+ }
+
+ /**
+ * The <code>easeOut()</code> method starts motion fast,
+ * and then decelerates motion as it executes.
+ *
+ * @param t Specifies time.
+ *
+ * @param b Specifies the initial position of a component.
+ *
+ * @param c Specifies the total change in position of the component.
+ *
+ * @param d Specifies the duration of the effect, in milliseconds.
+ *
+ * @param a Specifies the amplitude of the sine wave.
+ *
+ * @param p Specifies the period of the sine wave.
+ *
+ * @return Number corresponding to the position of the component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function easeOut(t:Number, b:Number,
+ c:Number, d:Number,
+ a:Number = 0, p:Number = 0):Number
+ {
+ if (t == 0)
+ return b;
+
+ if ((t /= d) == 1)
+ return b + c;
+
+ if (!p)
+ p = d * 0.3;
+
+ var s:Number;
+ if (!a || a < Math.abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ {
+ s = p / (2 * Math.PI) * Math.asin(c / a);
+ }
+
+ return a * Math.pow(2, -10 * t) *
+ Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
+ }
+
+ /**
+ * The <code>easeInOut()</code> method combines the motion
+ * of the <code>easeIn()</code> and <code>easeOut()</code> methods
+ * to start the motion slowly, accelerate motion, then decelerate.
+ *
+ * @param t Specifies time.
+ *
+ * @param b Specifies the initial position of a component.
+ *
+ * @param c Specifies the total change in position of the component.
+ *
+ * @param d Specifies the duration of the effect, in milliseconds.
+ *
+ * @param a Specifies the amplitude of the sine wave.
+ *
+ * @param p Specifies the period of the sine wave.
+ *
+ * @return Number corresponding to the position of the component.
+ *
+ * @langversion 3.0
+ * @playerversion Flash 9
+ * @playerversion AIR 1.1
+ * @productversion Flex 3
+ */
+ public static function easeInOut(t:Number, b:Number,
+ c:Number, d:Number,
+ a:Number = 0, p:Number = 0):Number
+ {
+ if (t == 0)
+ return b;
+
+ if ((t /= d / 2) == 2)
+ return b + c;
+
+ if (!p)
+ p = d * (0.3 * 1.5);
+
+ var s:Number;
+ if (!a || a < Math.abs(c))
+ {
+ a = c;
+ s = p / 4;
+ }
+ else
+ {
+ s = p / (2 * Math.PI) * Math.asin(c / a);
+ }
+
+ if (t < 1)
+ {
+ return -0.5 * (a * Math.pow(2, 10 * (t -= 1)) *
+ Math.sin((t * d - s) * (2 * Math.PI) /p)) + b;
+ }
+
+ return a * Math.pow(2, -10 * (t -= 1)) *
+ Math.sin((t * d - s) * (2 * Math.PI) / p ) * 0.5 + c + b;
+ }
+}
+
+}