Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import flash.geom.ColorTransform;
- import flash.display.BitmapDataChannel;
- import flash.filters.DisplacementMapFilter;
- import flash.geom.Point;
- import flash.geom.Matrix;
- import flash.events.Event;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.MovieClip;
- /**
- * @author Tatyana '0xFFFFFF' Belaya
- * perline.PerlineExp1
- */
- [SWF(width = 500, height=500)]
- public class PerlineExp1 extends MovieClip
- {
- private var pict : BitmapData;
- private var output : BitmapData;
- private var outputBmp : Bitmap;
- private var perlineNoize : BitmapData;
- private var perlineNoizeUpscaled : BitmapData;
- private var m : Matrix;
- private var origin : Point;
- private var displace : DisplacementMapFilter;
- private var scale : int;
- private var k : int;
- private var noizeCT : ColorTransform;
- private var noize : BitmapData;
- private var p1 : Point;
- private var p2 : Point;
- public function PerlineExp1()
- {
- pict = new BitmapData(100, 100);
- pict.perlinNoise(100, 100, 4, 3, false, true);
- m = new Matrix();
- m.translate(200, 200);
- output = new BitmapData(500, 500);
- outputBmp = new Bitmap(output);
- addChild(outputBmp);
- perlineNoize = new BitmapData(50, 50);
- perlineNoize.perlinNoise(10, 10, 3, 1, false, true);
- perlineNoizeUpscaled = new BitmapData(500, 500);
- noize = new BitmapData(500, 500);
- noize.noise(10);
- noizeCT = new ColorTransform();
- noizeCT.alphaMultiplier = .08;
- perlineNoize.draw(noize,null,noizeCT);
- origin = new Point();
- scale = 0;
- k = 1;
- p1 = new Point();
- p2 = new Point();
- addEventListener(Event.ENTER_FRAME, efHandler);
- }
- private function efHandler(event : Event) : void
- {
- output.fillRect(output.rect, 0xffffff);
- output.draw(pict, m);
- displace = new DisplacementMapFilter(
- perlineNoizeUpscaled,origin, BitmapDataChannel.RED,
- BitmapDataChannel.GREEN, scale, scale);
- output.applyFilter(output, output.rect,
- origin, displace);
- scale += 10*k;
- if(scale>=600) k = -1;
- if(scale<=0) k = 1;
- perlineNoize.perlinNoise(15, 15, 2, 1, false, true, 7,false,[p1, p2]);
- perlineNoizeUpscaled.draw(perlineNoize, new Matrix (10, 0, 0, 10), null, null, null, true);
- pict.perlinNoise(100, 100, 2, 3, false, true,7, false,[p2,p1]);
- perlineNoizeUpscaled.draw(noize,null,noizeCT);
- p1.offset(.5, .5);
- p2.offset(-3, -2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement