Advertisement
Guest User

Untitled

a guest
Sep 6th, 2010
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import flash.geom.ColorTransform;
  4.     import flash.display.BitmapDataChannel;
  5.     import flash.filters.DisplacementMapFilter;
  6.     import flash.geom.Point;
  7.     import flash.geom.Matrix;
  8.     import flash.events.Event;
  9.     import flash.display.Bitmap;
  10.     import flash.display.BitmapData;
  11.     import flash.display.MovieClip;
  12.    
  13.     /**
  14.      * @author Tatyana '0xFFFFFF' Belaya
  15.      * perline.PerlineExp1
  16.      */
  17.     [SWF(width = 500, height=500)]
  18.     public class PerlineExp1 extends MovieClip
  19.     {
  20.         private var pict : BitmapData;
  21.         private var output : BitmapData;
  22.         private var outputBmp : Bitmap;
  23.         private var perlineNoize : BitmapData;
  24.         private var perlineNoizeUpscaled : BitmapData;
  25.         private var m : Matrix;
  26.         private var origin : Point;
  27.         private var displace : DisplacementMapFilter;
  28.         private var scale : int;
  29.         private var k : int;
  30.         private var noizeCT : ColorTransform;
  31.         private var noize : BitmapData;
  32.         private var p1 : Point;
  33.         private var p2 : Point;
  34.  
  35.         public function PerlineExp1()
  36.         {
  37.             pict = new BitmapData(100, 100);
  38.             pict.perlinNoise(100, 100, 4, 3, false, true);
  39.             m = new Matrix();
  40.             m.translate(200, 200);
  41.            
  42.             output = new BitmapData(500, 500);
  43.             outputBmp = new Bitmap(output);
  44.             addChild(outputBmp);
  45.            
  46.             perlineNoize = new BitmapData(50, 50);
  47.             perlineNoize.perlinNoise(10, 10, 3, 1, false, true);
  48.  
  49.             perlineNoizeUpscaled = new BitmapData(500, 500);
  50.  
  51.             noize = new BitmapData(500, 500);
  52.             noize.noise(10);
  53.            
  54.             noizeCT = new ColorTransform();
  55.             noizeCT.alphaMultiplier = .08;
  56.             perlineNoize.draw(noize,null,noizeCT);
  57.            
  58.             origin = new Point();
  59.            
  60.             scale = 0;
  61.             k = 1;
  62.            
  63.             p1 = new Point();
  64.             p2 = new Point();
  65.            
  66.             addEventListener(Event.ENTER_FRAME, efHandler);
  67.         }
  68.  
  69.         private function efHandler(event : Event) : void
  70.         {
  71.             output.fillRect(output.rect, 0xffffff);
  72.             output.draw(pict, m);
  73.            
  74.             displace = new DisplacementMapFilter(
  75.                 perlineNoizeUpscaled,origin, BitmapDataChannel.RED,
  76.                     BitmapDataChannel.GREEN, scale, scale);
  77.             output.applyFilter(output, output.rect,
  78.                      origin, displace);
  79.                      
  80.             scale += 10*k;
  81.             if(scale>=600) k = -1;
  82.             if(scale<=0) k = 1;
  83.            
  84.             perlineNoize.perlinNoise(15, 15, 2, 1, false, true, 7,false,[p1, p2]);
  85.             perlineNoizeUpscaled.draw(perlineNoize, new Matrix (10, 0, 0, 10), null, null, null, true);
  86.             pict.perlinNoise(100, 100, 2, 3, false, true,7, false,[p2,p1]);
  87.             perlineNoizeUpscaled.draw(noize,null,noizeCT);
  88.            
  89.             p1.offset(.5, .5);
  90.             p2.offset(-3, -2);
  91.            
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement