forked from: 炎のアニメーション
borrowed some code from psyark's BumpyPlanet:
http://wonderfl.kayac.com/code/d79cd85845773958620f42cb3e6cb363c2020c73
[SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
// forked from XELF's 炎のアニメーション
// forked from Nao_u's 煙のアニメーション
// forked from Nao_u's forked from: Peak beta 1
// forked from shaktool's Peak beta 1
// forked from shaktool's Peak
// borrowed some code from psyark's BumpyPlanet:
// http://wonderfl.kayac.com/code/d79cd85845773958620f42cb3e6cb363c2020c73
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.text.*;
import flash.utils.*;
// [SWF(width=465, height=465, frameRate=60, backgroundColor=0x000000)]
public class Peak extends Sprite {
private var maskMap:BitmapData = new BitmapData(230,230,false,0);
private var heightMap:BitmapData = new BitmapData(230,230,false,0);
private var pos: Bitmap = new Bitmap(heightMap);
private var pos2: Bitmap = new Bitmap(maskMap);
private var palette: Array = new Array(256);
public var Tbl:Array = new Array;
public static function Clamp(value:Number):Number {
if (value < 0) return 0;
if (value > 255) return 255;
return value;
}
public function Peak() {
this.addEventListener(Event.ENTER_FRAME, generate);
Tbl[0] = new Point;
Tbl[1] = new Point;
Tbl[2] = new Point;
Tbl[3] = new Point;
// 下地
pos.scaleX = 2.0;
pos.scaleY = 2.0;
addChild(pos);
// マスク
pos2.scaleX = 2.0;
pos2.scaleY = 2.0;
pos2.blendMode = "add";
addChild(pos2);
// カラー変換テーブル
var v:Number;
for (var i:int = 0; i < 256; i++) {
v = (i + 48) * 2.5 - 350;
v += 48;
var R:Number = Clamp(v * 3.0);
var G:Number = Clamp(v * 1.5);
var B:Number = Clamp(v);
palette[i] = (R << 16) + (G << 8) + B;
}
// マスクの生成
maskMap.perlinNoise(1,1,4,0,true,true, 4, true);
var col:int, r:int, g:int, b:int;
var mul:Number, dx:Number, dy:Number, dist:Number;
var radius:Number = 130;
for (var x:int = 0; x < 230; x++) {
for (var y:int = 0; y < 230; y++) {
dx = Math.abs(115-x);
dy = Math.abs(115-y);
dist = Math.sqrt( dx*dx + dy*dy );
if( dist > radius ) dist = radius;
mul = (radius - dist) / radius;
col = maskMap.getPixel(x,y);
r = (col >> 16) & 0xff;
g = (col >> 8) & 0xff;
b = col & 0xff;
r = r * 1.50 + 1024 * mul * mul;
g = g * 0.75 + 1024 * mul * mul;
b = b * 0.50 + 1024 * mul * mul;
if( r > 255 ) r = 255;
if( g > 255 ) g = 255;
if( b > 255 ) b = 255;
r *= mul;
g *= mul;
b *= mul;
col = (r<<16) + (g<<8) + b;
maskMap.setPixel(x,y, col);
}
}
}
public function generate(event: Event): void {
// それぞれのレイヤーのスクロール速度
Tbl[0].x += 0.5;
Tbl[0].y += 1.35;
Tbl[1].x += -0.35;
Tbl[1].y += 2.05;
Tbl[2].x +=-0.05;
Tbl[2].y += 1.125;
Tbl[3].x += 0.1;
Tbl[3].y += 2.455;
heightMap.perlinNoise(40, 80, 4, 0, true, true, 4, false, Tbl);
// solarize:
heightMap.paletteMap(heightMap, new Rectangle(0,0,heightMap.width,heightMap.height),
new Point(0,0), null, null, palette, null);
}
}
}