Random Randbow Path (Smokey)
Added a fade and blur.
Created by: PESakaTFM
Inspired by http://www.loadedrecords.com/assets/plecs.swf
I don't know who made that one, but I kind of liked the idea.
Mine is different from the original that inspired me (I assume)
because I draw everything to a bitmap instead of using (and reusing)
lots of MovieClips.
I'm hoping this will give people more flexibility for effects.
/**
* Copyright PESakaTFM ( http://wonderfl.net/user/PESakaTFM )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/Aabq
*/
// forked from PESakaTFM's forked from: Random Randbow Path
// forked from PESakaTFM's Random Randbow Path
// Added a fade and blur.
/*
Created by: PESakaTFM
Inspired by http://www.loadedrecords.com/assets/plecs.swf
I don't know who made that one, but I kind of liked the idea.
Mine is different from the original that inspired me (I assume)
because I draw everything to a bitmap instead of using (and reusing)
lots of MovieClips.
I'm hoping this will give people more flexibility for effects.
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.filters.DisplacementMapFilter;
import flash.geom.Matrix;
import flash.geom.Point;
[SWF(width=600, height=360, backgroundColor='#000000', frameRate=30)]
public class Main extends Sprite
{
public const MAX:int = 30;
public var lastType:int = 2;
public var curType:int = 0;
public var gy:int = 0;
public var gx:int = 0;
public var dir:int = 0;
public var path:CurvingPath;
public var perlin:BitmapData;
public var offset:Array;
public var seed:Number;
public var displace:DisplacementMapFilter;
public var bmp:Bitmap;
public var bmd:BitmapData;
public var matrix:Matrix;
public var blur:BlurFilter = new BlurFilter(5,5,2);
public var fade:ColorMatrixFilter = new ColorMatrixFilter([.98,0,.04,0,0,
.04,.98,0,0,0,
0,.04,.98,0,0,
0,0,0,1,0]);
public var GridSize:Point = new Point(5,3);
public function Main()
{
path = new CurvingPath();
path.end = step;
path.draw = draw;
this.perlin = new BitmapData(600, 360, false, 0);
seed = Math.random()*1000;
offset = [new Point(0,0)];
this.perlin.perlinNoise(100,100,1,seed,false,true,3,false,offset);
this.displace = new DisplacementMapFilter(perlin, null,1,2,5,-2);
bmd = new BitmapData(600, 360, false, 0);
bmp = new Bitmap(bmd, 'auto', true);
matrix = new Matrix(1,0,0,1,0,0);
this.addChild(bmp);
step();
}
protected function draw():void
{
var angle:Number = Math.PI * .5 * dir;
matrix.a = matrix.d = Math.cos(angle);
matrix.b = Math.sin(angle);
matrix.c = -matrix.b;
matrix.tx = gx*120;
matrix.ty = gy*120;
bmd.draw(path, matrix, null, null, null, true);
bmd.applyFilter(bmd,bmd.rect,new Point(0,0), fade);
bmd.applyFilter(bmd,bmd.rect,new Point(0,0), blur);
bmd.applyFilter(bmd,bmd.rect,new Point(0,0), displace);
}
protected function step():void
{
curType = Math.floor(2.99*Math.random());
if(lastType == 0)
{
dir += 1;
}
else if(lastType == 1)
{
switch(dir)
{
case 0:
gy += 1;
gx += 1;
break;
case 1:
gy += 1;
gx -= 1;
break;
case 2:
gy -= 1;
gx -= 1;
break;
case 3:
gy -= 1;
gx += 1;
break;
}
dir -= 1;
}
else if(lastType == 2)
{
switch(dir)
{
case 0:
gy += 1;
break;
case 1:
gx -= 1;
break;
case 2:
gy -= 1;
break;
case 3:
gx += 1;
break;
}
}
if(dir == 4) dir = 0;
else if(dir == -1) dir = 3;
switch(dir)
{
case 0:
if(gy >= GridSize.y) gy = 0;
if(gx >= GridSize.x) gx = 0;
if(gy < 0) gy = GridSize.y-1;
if(gx < 0) gx = GridSize.x-1;
break;
case 1:
if(gy >= GridSize.y) gy = 0;
if(gx > GridSize.x) gx = 1;
if(gy < 0) gy = GridSize.y-1;
if(gx <= 0) gx = GridSize.x;
break;
case 2:
if(gy > GridSize.y) gy = 1;
if(gx > GridSize.x) gx = 1;
if(gy <= 0) gy = GridSize.y;
if(gx <= 0) gx = GridSize.x;
break;
case 3:
if(gy > GridSize.y) gy = 1;
if(gx >= GridSize.x) gx = 0;
if(gy <= 0) gy = GridSize.y;
if(gx < 0) gx = GridSize.x-1;
break;
}
path.init(curType);
lastType = curType;
}
}
}
import flash.display.Sprite;
import flash.events.Event;
import flash.display.Graphics;
class CurvingPath extends Sprite
{
private var count:int = 30;
public var type:int = 0;
public var end:Function;
public var draw:Function;
public const COLORS:Array = [0xFF0000, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF, 0xFF00FF];
public const LINE_WIDTH:int = 15;
public const SQUARE_WIDTH:int = 120;
public function CurvingPath()
{
}
public function init(type:int = 0):void
{
this.graphics.clear();
this.type = type;
this.count = 15;
this.addEventListener(Event.ENTER_FRAME, onEnter);
}
protected function onEnter(e:Event):void
{
count--;
var i:int = 0;
var a:int = 0;
var angle1:int = 90-((count+1)*6);
var angle2:int = 90-(count*6);
var h1:int = this.SQUARE_WIDTH-((count+1)*8);
var h2:int = this.SQUARE_WIDTH-(count*8);
var g:Graphics = this.graphics;
g.clear();
if(this.type == 0)
{
for(i=0; i<6; i)
{
g.beginFill(COLORS[i], 1);
g.moveTo(i*LINE_WIDTH*Math.cos(Math.PI*angle1/180), i*LINE_WIDTH*Math.sin(Math.PI*angle1/180));
for(a=angle1; a<=angle2; a++)
{
g.lineTo(i*LINE_WIDTH*Math.cos(Math.PI*a/180), i*LINE_WIDTH*Math.sin(Math.PI*a/180));
}
i++;
for(a; a>=angle1; a--)
{
g.lineTo(i*LINE_WIDTH*Math.cos(Math.PI*a/180), i*LINE_WIDTH*Math.sin(Math.PI*a/180));
}
g.endFill();
}
}
else if(this.type == 1)
{
for(i=2; i<8; i)
{
g.beginFill(COLORS[7-i], 1);
g.moveTo(i*LINE_WIDTH*Math.cos(Math.PI*(180-angle1)/180)+SQUARE_WIDTH, i*LINE_WIDTH*Math.sin(Math.PI*(180-angle1)/180));
for(a=angle1; a<=angle2; a++)
{
g.lineTo(i*LINE_WIDTH*Math.cos(Math.PI*(180-a)/180)+SQUARE_WIDTH, i*LINE_WIDTH*Math.sin(Math.PI*(180-a)/180));
}
i++;
for(a; a>=angle1; a--)
{
g.lineTo(i*LINE_WIDTH*Math.cos(Math.PI*(180-a)/180)+SQUARE_WIDTH, i*LINE_WIDTH*Math.sin(Math.PI*(180-a)/180));
}
g.endFill();
}
}
else if(this.type == 2)
{
for(i=0; i<6; i)
{
g.beginFill(COLORS[i], 1);
g.moveTo(i*LINE_WIDTH, h1);
g.lineTo(i*LINE_WIDTH, h2);
i++;
g.lineTo(i*LINE_WIDTH, h2);
g.lineTo(i*LINE_WIDTH, h1);
g.endFill();
}
}
draw();
if(count <= 0)
{
this.removeEventListener(Event.ENTER_FRAME, onEnter);
end();
}
}
}