炎のアニメーション(60x60)
borrowed some code from psyark's BumpyPlanet:
http://wonderfl.kayac.com/code/d79cd85845773958620f42cb3e6cb363c2020c73
// forked from hamuhamu's 炎のアニメーション(60x60)
// 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(60,60,false,0);
private var heightMap:BitmapData = new BitmapData(60,60,false,0);
private var pos: Bitmap = new Bitmap(heightMap);
private var palette: Array = new Array(256);
private var offset:Number = Math.random();
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() {
stage.addEventListener(Event.ENTER_FRAME, generate);
Tbl[0] = new Point;
Tbl[1] = new Point;
Tbl[2] = new Point;
Tbl[3] = new Point;
// 下地
pos.scaleX = 8.0;
pos.scaleY = 8.0;
addChild(pos);
pos.stage.frameRate = 30;
// カラー変換テーブル
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(0.1,0.1,6,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 < 60; x++) {
for (var y:int = 0; y < 60; 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 += offset;
Tbl[0].y -= 3;
Tbl[1].y += 6;
Tbl[2].y += 4;
Tbl[3].y -= 6;
var num:Number = Math.random() * 1.3;
heightMap.perlinNoise(120, 120, 5 - num, 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);
}
}
}