Frame 1
function generateFractal(repeat) {
if (repeat) {
invader.perlinNoise(mapWidth / 2, mapHeight / 2, randomOctave, randomSeed, false, false, randomColor, false);
} else {
if (Key.isToggled(20)) {
hold = true;
} else {
hold = false;
}
if (hold == false) {
randomOctave = Math.floor((Math.random() * 25) + 1);
randomColor = Math.floor((Math.random() * 15) + 1);
}
randomSeed = Math.floor((Math.random() * 50) + 1);
invader.perlinNoise(mapWidth / 2, mapHeight / 2, randomOctave, randomSeed, false, false, randomColor, false);
if (hold == true) {
setThreshold(theThreshold);
}
}
var _local2 = 0;
while (_local2 < mapHeight) {
var _local1 = 0;
while (_local1 < mapHalfWidth) {
invader.setPixel32((mapWidth - _local1) - 1, _local2, invader.getPixel32(_local1, _local2));
_local1++;
}
_local2++;
}
}
function setThreshold(theThreshold) {
invader.threshold(invader, new flash.geom.Rectangle(0, 0, mapWidth, mapHeight), new flash.geom.Point(0, 0), ">=", Math.abs(theThreshold), 4278190080);
invader.threshold(invader, new flash.geom.Rectangle(0, 0, mapWidth, mapHeight), new flash.geom.Point(0, 0), "<", Math.abs(theThreshold), 16777215);
invader.applyFilter(invader, invader.rectangle, new flash.geom.Point(0, 0), fractalBlur);
}
function changeBlur(blurDirection) {
if ((blurLength > 1) || (blurDirection == 1)) {
blurLength = blurLength + blurDirection;
fractalBlur.blurX = blurLength;
fractalBlur.blurY = blurLength;
invader.applyFilter(invader, invader.rectangle, new flash.geom.Point(0, 0), fractalBlur);
}
}
var mapWidth = Stage.width;
var mapHeight = Stage.height;
var mapHalfWidth = Math.floor(mapWidth / 2);
var hold = false;
var theThreshold;
var blurLength = 2;
var blurQuality = 1;
var randomOctave;
var randomSeed;
var randomColor;
var invader = (new flash.display.BitmapData(mapWidth, mapHeight, true, 16777215));
var mc_1 = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
mc_1.attachBitmap(invader, this.getNextHighestDepth());
generateFractal();
var fractalBlur = (new flash.filters.BlurFilter(blurLength, blurLength, blurQuality));
mc_1.onRelease = function () {
generateFractal();
};
var keyListener = new Object();
keyListener.onKeyDown = function () {
if (Key.isDown(32)) {
trace("Octave = " + randomOctave);
trace("Seed = " + randomSeed);
trace("Color Setting = " + randomColor);
trace("Threshold = " + theThreshold);
}
if (Key.isDown(17)) {
theThreshold = invader.getPixel32(Math.floor(_root._xmouse), Math.floor(_root._ymouse));
setThreshold(invader.getPixel32(Math.floor(_root._xmouse), Math.floor(_root._ymouse)));
}
if (Key.isDown(37)) {
generateFractal(true);
}
if (Key.isDown(38)) {
changeBlur(1);
}
if (Key.isDown(40)) {
changeBlur(-1);
}
};
Key.addListener(keyListener);