forked from: Peak
forked from Peak (diff: 675)
ActionScript3 source code
/**
* Copyright shaktool ( http://wonderfl.net/user/shaktool )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sWbX
*/
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
[SWF(width=400, height=465, frameRate=15, backgroundColor=0x000000)]
public class Peak extends Sprite {
private const WIDTH: int = 100;
private const HEIGHT: int = 100;
private const W_TIMES_H: int = WIDTH*HEIGHT;
private var lifeMap: BitmapData = new BitmapData(WIDTH, HEIGHT, false , 0);
//private var heatMap: BitmapData = new BitmapData(WIDTH, HEIGHT, false, 0);
private var heightMap:BitmapData = new BitmapData(WIDTH,HEIGHT,false,0);
private var tempMap:BitmapData = new BitmapData(WIDTH,HEIGHT,true,0);
public function Peak() {
stage.addEventListener(MouseEvent.CLICK, generate);
generate(null);
var screen: Bitmap = new Bitmap(heightMap);
screen.scaleX = 2;
screen.scaleY = 2;
addChild(screen);
}
public function generate(event: MouseEvent): void {
var i: int;
var j: int;
var k: int;
var palette: Array = new Array(256);
var threshold: int;
heightMap.perlinNoise(50,50,10,Math.random()*int.MAX_VALUE,true,true, 7, false);
/*
// solarize and copy into heightmap:
threshold = 100;
for (i = 0; i < 128; i++) {
if (i < threshold) k = 0; else k = (i - threshold) * 255 / (127 - threshold);
k = (k << 16) | (k << 8) | (k << 0);
palette[i] = k;
palette[255 - i] = k;
}
heightMap.paletteMap(heightMap, new Rectangle(0,0,WIDTH,HEIGHT), new Point(0,0), null, null, palette, null);
*/
}
}
}
