Most easing equations give a smooth, gradual transition between the start and end values, but RoughEase provides
an easy way to get a rough, jagged effect instead. You can define an ease that it will use as a template (like a
general guide - Linear.easeNone is the default) and then it will randomly plot points that wander from that template.
The strength parameter controls how far from the template ease the points are allowed to go (a small number like
0.1 keeps it very close to the template ease whereas a larger number like 2 creates much larger jumps). You can
also control the number of points in the ease, making it jerk more or less frequently. And lastly, you can associate
a name with each RoughEase instance and retrieve it later like RoughEase.byName("myEaseName"). Since creating
the initial RoughEase is the most processor-intensive part, it's a good idea to reuse instances if/when you can.
EXAMPLE CODE
import com.greensock.TweenLite;
import com.greensock.easing.RoughEase;
TweenLite.from(mc, 3, {alpha:0, ease:RoughEase.create(1, 15)});
//or create an instance directly
var rough:RoughEase = new RoughEase(1.5, 30, true, Strong.easeOut, "none", true, "superRoughEase");
TweenLite.to(mc, 3, {y:300, ease:rough.ease});
//and later, you can find the ease by name like:
TweenLite.to(mc, 3, {y:300, ease:RoughEase.byName("superRoughEase")});
Copyright 2010, GreenSock. All rights reserved. This work is subject to the terms in
http://www.greensock.com/terms_of_use.html or for corporate Club GreenSock members, the software agreement that was issued with the corporate membership.
name:String
[read-write]
name of the RoughEase instance
Implementation
public function get name():String
public function set name(value:String):void
public function RoughEase(strength:Number = 1, points:uint = 20, restrictMaxAndMin:Boolean = false, templateEase:Function = null, taper:String = "none", randomize:Boolean = true, name:String = "")
Constructor
Parameters
| strength:Number (default = 1 ) — amount of variance from the templateEase (Linear.easeNone by default) that each random point can be placed. A low number like 0.1 will hug very closely to the templateEase whereas a larger number like 2 will allow the values to wander further away from the templateEase.
|
|
| points:uint (default = 20 ) — quantity of random points to plot in the ease. A larger number will cause more (and quicker) flickering.
|
|
| restrictMaxAndMin:Boolean (default = false ) — If true, the ease will prevent random points from exceeding the end value or dropping below the starting value. For example, if you're tweening the x property from 0 to 100, the RoughEase would force all random points to stay between 0 and 100 if restrictMaxAndMin is true, but if it is false, a x could potentially jump above 100 or below 0 at some point during the tween (it would always end at 100 though).
|
|
| templateEase:Function (default = null ) — an easing equation that should be used as a template or guide. Then random points are plotted at a certain distance away from the templateEase (based on the strength parameter). The default is Linear.easeNone.
|
|
| taper:String (default = "none ") — to make the strength of the roughness taper towards the end or beginning, use "out" or "in" respectively here (default is "none") .
|
|
| randomize:Boolean (default = true ) — to randomize the placement of the points, set randomize to true (otherwise the points will zig-zag evenly across the ease)
|
|
| name:String (default = " ") — a name to associate with the ease so that you can use RoughEase.byName() to look it up later. Of course you should always make sure you use a unique name for each ease (if you leave it blank, a name will automatically be generated).
|
public static function byName(name:String):Function
Provides a quick way to look up a RoughEase by its name.
Parameters
| name:String — the name of the RoughEase
|
Returns
| Function — easing function from the RoughEase associated with the name
|
public static function create(strength:Number = 1, points:uint = 20, restrictMaxAndMin:Boolean = false, templateEase:Function = null, taper:String = "none", randomize:Boolean = true, name:String = ""):Function
This static function provides a quick way to create a RoughEase and immediately reference its ease function
in a tween, like:
TweenLite.from(mc, 2, {alpha:0, ease:RoughEase.create(1.5, 15)});
Parameters
| strength:Number (default = 1 ) — amount of variance from the templateEase (Linear.easeNone by default) that each random point can be placed. A low number like 0.1 will hug very closely to the templateEase whereas a larger number like 2 will allow the values to wander further away from the templateEase.
|
|
| points:uint (default = 20 ) — quantity of random points to plot in the ease. A larger number will cause more (and quicker) flickering.
|
|
| restrictMaxAndMin:Boolean (default = false ) — If true, the ease will prevent random points from exceeding the end value or dropping below the starting value. For example, if you're tweening the x property from 0 to 100, the RoughEase would force all random points to stay between 0 and 100 if restrictMaxAndMin is true, but if it is false, a x could potentially jump above 100 or below 0 at some point during the tween (it would always end at 100 though).
|
|
| templateEase:Function (default = null ) — an easing equation that should be used as a template or guide. Then random points are plotted at a certain distance away from the templateEase (based on the strength parameter). The default is Linear.easeNone.
|
|
| taper:String (default = "none ") — to make the strength of the roughness taper towards the end or beginning, use "out" or "in" respectively here (default is "none") .
|
|
| randomize:Boolean (default = true ) — to randomize the placement of the points, set randomize to true (otherwise the points will zig-zag evenly across the ease)
|
|
| name:String (default = " ") — a name to associate with the ease so that you can use RoughEase.byName() to look it up later. Of course you should always make sure you use a unique name for each ease (if you leave it blank, a name will automatically be generated).
|
Returns
| Function — easing function
|
public function ease(t:Number, b:Number, c:Number, d:Number):Number
Easing function that interpolates the numbers
Parameters
| t:Number — time
|
|
| b:Number — start
|
|
| c:Number — change
|
|
| d:Number — duration
|
Returns
| Number — Result of the ease
|