forked from: Using Easing Funcitons
/**
* Copyright onedayitwillmake ( http://wonderfl.net/user/onedayitwillmake )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/pGQQ
*/
// forked from 9re's Using Easing Funcitons
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.Timer;
import mx.effects.easing.*;
import frocessing.color.ColorHSV;
import caurina.transitions.Equations;
[SWF(width = '465', height = '465', frameRate = '20', backgroundColor='#1a1a1a') ]
public class EasingFunctionTest extends Sprite {
private var _time:int = 0;
private var _bd:BitmapData;
private var _converter:ColorHSV = new ColorHSV();
private var _s:int = 100;
private var currentColor:int = Math.random() * 360;
private var colorIncreaseHorizontal:int = 10;
private var currentSat:Number = 1;
private var satIncrease:Number = 0.01;
public function EasingFunctionTest() {
_bd = new BitmapData(_s, _s, false, 0);
addChild(new Bitmap(_bd));
//_bd.applyFilter(_bd, _bd.rect, zero, blur);
getChildAt(0).scaleX = getChildAt(0).scaleY = 4.65/// 2;
addEventListener(Event.ENTER_FRAME, enterFrameHandler);
// var timer:Timer = new Timer(1000 / stage.frameRate);
//timer.addEventListener(TimerEvent.TIMER, timerHandler);
// timer.start();
}
// private var blur:BlurFilter = new BlurFilter(0, 32, 2);
private var blur:BlurFilter = new BlurFilter(32, 32, 3);
private var color:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, -16);
private var zero:Point = new Point(0, 0);
private function timerHandler(e:TimerEvent):void {
// _bd.lock();
// _bd.unlock();
}
private var rec:Rectangle = new Rectangle(0, 0, _s, _s);
private function enterFrameHandler(e:Event):void {
var i:int, j:int;
var loop:int = 800
//_converter.
currentColor = (currentColor + colorIncreaseHorizontal)// % 720;j
if (currentSat >= 2 && satIncrease >= 0) satIncrease *= -1;
else if (currentSat <= 0.5 && satIncrease <= 0) satIncrease *= -1;
// currentSat = (currentSat + satIncrease);
_bd.lock();
for (i = 0; i < _s; ++i)
{
for (j = 0; j < _s; ++j)
{
_converter.hsv
(
currentColor + Equations.easeOutInQuad(i, _time, loop + _time, _s),
currentSat,
Equations.easeInOutElastic(j, 0.1, 1 + Math.random(), _s)
);
//
if(Math.random() < 0.5)
_bd.setPixel(i, j, _converter.value );
}
}
_bd.applyFilter(_bd, _bd.rect, zero, blur);
_bd.unlock();
//_bd.colorTransform(rec, color);
//trace(_time)
//_time += stage.frameRate / 10;
//_time %= stage.frameRate * 10;
}
}
}