/**
* Copyright curvedstraightline ( http://wonderfl.net/user/curvedstraightline )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sbk6
*/
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.MovieClip;
import flash.display.GradientType;
import flash.display.SpreadMethod;
import flash.display.InterpolationMethod;
import flash.geom.Matrix;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.events.Event;
import flash.geom.Point;
public class FlashTest extends MovieClip
{
public const STAGE_WIDTH:Number = stage.stageWidth;
public const STAGE_HEIGHT:Number = stage.stageHeight;
public const STAGE_SCALE:Number = 1;
public function FlashTest() {
//makeGD();
bw_perlin();
perlin();
stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);
}
//グラデーション用
public var gd_sh:Shape = new Shape();
public var gd_mc:MovieClip = new MovieClip();
public const gd_type:String = GradientType.LINEAR;
public const gd_color:Array = [0xffffff,0x000000];
public const gd_alpha:Array = [1,1];
public const gd_ratio:Array = [0,250];
public const gd_spreadMethod:String = SpreadMethod.PAD;
public const gd_interp:String = InterpolationMethod.LINEAR_RGB;
public const gd_focalPtRatio:Number = 0;
public var gd_matrix:Matrix = new Matrix();
public function makeGD():void
{
gd_matrix.createGradientBox(STAGE_WIDTH,STAGE_HEIGHT,Math.PI/2,0,0);
gd_sh.graphics.beginGradientFill(
gd_type,
gd_color,
gd_alpha,
gd_ratio,
gd_matrix,
gd_spreadMethod,
gd_interp,
gd_focalPtRatio
);
gd_sh.graphics.drawRect(0, 0, STAGE_WIDTH, STAGE_HEIGHT);
gd_mc.addChild(gd_sh);
stage.addChild(gd_mc);
}
//白黒のパーリン
public var bw_perlin_sp:Sprite = new Sprite();
public var bw_perlin_mc:MovieClip = new MovieClip();
public var bw_perlin_mt:Matrix = new Matrix();
public var bw_perlin_bp:Bitmap = new Bitmap();
public var bw_perlin_bmd:BitmapData = new BitmapData(
STAGE_WIDTH,
STAGE_HEIGHT,
false,
0xffffff
);
public function bw_perlin():void
{
bw_perlin_bp.bitmapData = bw_perlin_bmd;
bw_perlin_bp.scaleX = bw_perlin_bp.scaleY = STAGE_SCALE + .1;
bw_perlin_sp.addChild(bw_perlin_bp);
bw_perlin_mc.addChild(bw_perlin_sp);
bw_perlin_mc.blendMode = BlendMode.MULTIPLY;
stage.addChild(bw_perlin_mc);
//bw_perlin.mask = gd_mc;
}
//通常のパーリン
public var perlin_sp:Sprite = new Sprite();
public var perlin_mc:MovieClip = new MovieClip();
public var perlin_mt:Matrix = new Matrix();
public var perlin_bp:Bitmap = new Bitmap();
public var perlin_bmd:BitmapData = new BitmapData(
STAGE_WIDTH,
STAGE_HEIGHT,
false,
0xffffff
);
public function perlin():void
{
perlin_bp.bitmapData = perlin_bmd;
perlin_bp.scaleX = perlin_bp.scaleY = STAGE_SCALE + .1;
perlin_sp.addChild(perlin_bp);
perlin_mc.addChild(perlin_sp);
perlin_mc.blendMode = BlendMode.MULTIPLY;
stage.addChild(perlin_mc);
}
public const BW_BASE_X:int = STAGE_WIDTH / 11;
public const BW_BASE_Y:int = STAGE_HEIGHT;
public const BW_OCTAVE_NUMBER:uint = 1;
public const BW_RANDOM_SEED:int = Math.floor(Math.random() * 0xffffff);
public var BW_CHANNEL_OPTION:int = 1;
public var bw_offset_array:Array = [new Point(),new Point(), new Point()];
public const BASE_X:int = STAGE_WIDTH ;
public const BASE_Y:int = STAGE_HEIGHT * 10;
public const OCTAVE_NUMBER:uint = 1;
public var RANDOM_SEED:int = Math.floor(Math.random() * 0xffffff);
public const CHANNEL_OPTION:int = 7;
public var offset_array:Array = [new Point(),new Point(), new Point()];
public function onEnterFrame(e:Event):void
{
bw_perlin_bmd.perlinNoise(
BW_BASE_X,
BW_BASE_Y,
BW_OCTAVE_NUMBER,
BW_RANDOM_SEED,
true,
true,
BW_CHANNEL_OPTION,
true,
bw_offset_array
);
bw_offset_array[0].y += 10;
bw_offset_array[0].x += 1;
bw_offset_array[2].x -= 10;
perlin_bmd.perlinNoise(
BASE_X,
BASE_Y,
OCTAVE_NUMBER,
RANDOM_SEED,
false,
false,
CHANNEL_OPTION,
false,
offset_array
);
offset_array[0].y += 80;
offset_array[2].x -= 10;
}
}
}