RainBow
/**
* Copyright jokehn9 ( http://wonderfl.net/user/jokehn9 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/rlet
*/
package {
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.geom.Point;
import flash.display.Shape;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
// write as3 code here..
var circleO:BitmapData = new BitmapData(465,465,true);
var rainbow:Array = [Math.random()*0xffffff, Math.random()*0xffffff, Math.random()*0xffffff, Math.random()*0xffffff, Math.random()*0xffffff, Math.random()*0xffffff, Math.random()*0xffffff];
var back:Shape = new Shape();
back.graphics.beginFill(0xffff);
back.graphics.drawRect(0,0,465,465);
//circleO.draw(back);
function circle(bd:BitmapData, cx:int, cy:int, R:Number, color:uint,acc:int):void {
var p:Number = 1.25 - R
var x:int = 0, y:int = R
var i:Number = 0 ;
for(i=0;i<R;i+=2) {
bd.setPixel(cx, cy+R-i, color)
bd.setPixel(cx, cy-R+i, color)
bd.setPixel(cx+R-i, cy, color)
bd.setPixel(cx-R+i, cy, color)
while(x < y){
x+=1;
if(p < 0){
p += x*2 -1 ;
}else{
y-=1;
p += x*2 -1 - y*acc;
color = rainbow[x%7];
}
bd.setPixel(cx+x, cy+y, color)
bd.setPixel(cx-x, cy+y, color)
bd.setPixel(cx+x, cy-y, color)
bd.setPixel(cx-x, cy-y, color)
bd.setPixel(cx+y, cy+x, color)
bd.setPixel(cx-y, cy+x, color)
bd.setPixel(cx+y, cy-x, color)
bd.setPixel(cx-y, cy-x, color)
}
x = 0;
y = R-i;
p = 1.25 - y;
}
var k:int = 0;
for(i=0;i<465;i++) {
for(k=0;k<465;k++) {
if(bd.getPixel(i,k) >= 0xffffff) {
bd.setPixel(i,k,bd.getPixel(i-1,k-1)&0x444444);
}
else {
bd.setPixel(i,k,bd.getPixel(i,k)<<1);
}
}
}
}
stage.addEventListener(MouseEvent.CLICK,click);
var ck:int = 3;
function click(e:MouseEvent):void {
circle(circleO,232,232,400,0xff0000,ck);
ck++;
}
circle(circleO, 232,232,400,0xff0000,2);
//circleO.applyFilter(circleO,circleO.rect, new Point, new BlurFilter(4,4));
var i:int = 0;
var k:int = 0;
addChild(new Bitmap(circleO));
}
}
}