flash on 2015-1-31
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/b3y7
*/
package {
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.geom.Matrix;
import flash.display.BlendMode;
import flash.display.BitmapData;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
var tmp:BitmapData;
tmp = new BitmapData(465,465, false, 0);
var mask:BitmapData;
mask = new BitmapData(465,465, false, 0);
var pic:BitmapData;
pic = new BitmapData(465,465, false, 0);
var ct:ColorTransform;
ct = new ColorTransform(0,1,0);
var skin:BitmapData;
skin = new BitmapData(64, 8, true, 0);
skin.perlinNoise(23,53,5,5,true,true,7,true);
skin.colorTransform(skin.rect, ct);
ct = new ColorTransform(0.4, 0.2, 0.3);
var skin2:BitmapData;
skin2 = new BitmapData(64, 8, true,0);
skin2.perlinNoise(11,4,2,4,true,true,7,true);
skin2.colorTransform(skin2.rect, ct);
for (i =0; i<128;i++)
{
graphics.beginFill(Math.random()<0.5?0:0xFFffFF,1);
graphics.drawCircle(Math.random()*465, Math.random()*465, Math.random()*64+8);
graphics.endFill();
}
graphics.beginFill(0xFFffFF,1);
graphics.drawCircle(465*0.5, 465*0.5, 128);
graphics.endFill();
graphics.beginFill(0, 1);
graphics.drawCircle(465*0.5, 465*0.5, 64);
graphics.endFill();
mask.draw(this);
var mat:Matrix;
mat = new Matrix();
//tmp.noise(32);
tmp.perlinNoise(23,43,5,3, true,false,7,true);
//mat.ty = 16;
//tmp.draw(mask);
//mat.tx = 16;
tmp.draw(mask, mat, null, BlendMode.MULTIPLY);
// mat.tx = -16;
// tmp.draw(mask, mat, null, BlendMode.ADD);
pic.draw(tmp);
var p:Point;
var r:Rectangle;
p = new Point();
r = new Rectangle(0,0,1, 8);
var i:int; var k:int; var w:int;
for (k = 0; k < 465; k+=1)
for (i = 0; i < 465; i+=1)
{
if (mask.getPixel(k,i) != 0)
if (mask.getPixel(k,i-1) == 0)
{
//for (w =0; w<8;w++) {pic.setPixel(k,i+w,0xFF0000);}
p.x = k; p.y = i;
r.x = (k % skin.width);
pic.copyPixels(skin, r, p);
i+= 8;
}
if (mask.getPixel(k,i) == 0)
if (mask.getPixel(k,i-1) !=0)
{
//for (w=0;w <8;w++) { pic.setPixel(k,i-w,0xFF);}
p.x = k; p.y = i - 8;
r.x = (k % skin.width);
pic.copyPixels(skin2, r, p);
i+=1;
}
}
graphics.clear();
graphics.beginBitmapFill(pic,null,false,false);
graphics.drawRect(0,0,465,465);
graphics.endFill();
}//ctor
}//classend
}