※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


forked from : beinteractive's forked from: 10万個ぱーてぃくる - 軽く高速化 [diff(43)]

FAVORITE BY
:
:
:
linux fp10でもヌルヌル動く
:
:
:
かっちぇ
:
祭りの後は、やっぱ炎上ですね!
:
パーティクル祭祭りの後に炎上とはこれ如何に
:
炎上こくばんせんせいは炎上大好き♪ きっと仕事でmぅわなにをするry
:
FORKED
  1. // forked from munegon's 炎上シマスタ
  2. // forked from beinteractive's forked from: 10万個ぱーてぃくる - 軽く高速化
  3. // forked from bkzen's 10万個ぱーてぃくる
  4. package  
  5. {
  6.     import flash.display.Sprite;
  7.     import flash.display.StageAlign;
  8.     import flash.display.StageScaleMode;
  9.     import flash.events.Event;
  10.     import flash.events.MouseEvent;
  11.     import net.hires.debug.Stats;
  12.     
  13.     /**
  14.      * なんかいっぱい動かすテスト
  15.      * 洗濯機みたいになってます。
  16.      * @author jc at bk-zen.com
  17.      */
  18.     [SWF(backgroundColor = "0x000000", frameRate = "30")]
  19.     public class Test3 extends Sprite
  20.     {
  21.         protected const NUM_OF_PARTICLES: int = 100000;
  22.         private var main: TestMain;
  23.         
  24.         public function Test3() 
  25.         {
  26.             if (stage) init();
  27.             else addEventListener(Event.ADDED_TO_STAGE, init);
  28.         }
  29.         
  30.         private function init(e:Event = null):void 
  31.         {
  32.             removeEventListener(Event.ADDED_TO_STAGE, init);
  33.             //
  34.             main = new TestMain(stage.stageWidth, stage.stageHeight, NUM_OF_PARTICLES);
  35.             addChild(main.view);
  36.             addChild(new Stats());
  37.             stage.scaleMode = StageScaleMode.NO_SCALE;
  38.             stage.align = StageAlign.TOP_LEFT;
  39.             stage.addEventListener(Event.RESIZE, onResize);
  40.             stage.addEventListener(MouseEvent.CLICK, onClick);
  41.             addEventListener(Event.ENTER_FRAME, onEnter);
  42.             
  43.         }
  44.         
  45.         private function onClick(e:MouseEvent):void 
  46.         {
  47.             main.change();
  48.         }
  49.         
  50.         private function onEnter(e:Event):void 
  51.         {
  52.             main.draw(mouseX, mouseY);
  53.         }
  54.         // りサイズ (未実装)
  55.         private function onResize(e:Event):void 
  56.         {
  57.             main.resize(stage.stageWidth, stage.stageHeight);
  58.         }
  59.     }
  60. }
  61. import flash.display.Bitmap;
  62. import flash.display.BitmapData;
  63. import flash.geom.ColorTransform;
  64. import flash.geom.Point;
  65. import flash.utils.ByteArray;
  66. import flash.utils.Timer;
  67. import flash.events.TimerEvent;
  68. import flash.filters.BlurFilter;
  69. class TestMain
  70. {
  71.     private var w: int;
  72.     private var h: int;
  73.     private var mw: int;
  74.     private var mh: int;
  75.     public var view: Bitmap;
  76.     private var bmpData: BitmapData;
  77.         private var buf: BitmapData;
  78.     private var forceMap: BitmapData;
  79.     private var randomSeed: int;
  80.     private var particles: Particle;
  81.         private var bf: BlurFilter;
  82.         private var rPalette: Array;
  83.         private var gPalette: Array;
  84.         private var bPalette: Array;
  85.     private var num: int;
  86.     private var color: uint = 0xFFFFFF;
  87.     private var count: int = 0;
  88.     private var colorTr: ColorTransform;
  89.     
  90.     public function TestMain(w: int, h: int, numOfParticles: int)
  91.     {
  92.         this.w = w;
  93.         mw = w >> 1;
  94.         this.h = h;
  95.         mh = h >> 1;
  96.         bmpData = new BitmapData(w, h, false, 0x00000000);
  97.                 buf = bmpData.clone();
  98.         forceMap = new BitmapData(mw, mh, false);
  99.         forceMap.perlinNoise(mw >> 1, mh >> 14, Math.random() * 0xFFFF, falsetrue3);
  100.         view = new Bitmap(bmpData);
  101.                 bf = new BlurFilter( 16163 );
  102.                 rPalette = new Array256 );
  103.                 gPalette = new Array256 );
  104.                 bPalette = new Array256 );
  105.         num = numOfParticles;
  106.         var i: int;
  107.         var prev: Particle = particles = new Particle();
  108.         var p: Particle;
  109.         while (++i <= num)
  110.         {
  111.             p = new Particle();
  112.             p.x = Math.random() * w;
  113.             p.y = Math.random() * h;
  114.             prev.next = p;
  115.             prev = p;
  116.         }
  117.                 for ( var n:int = 0; n <= 0xff; ++n ) {
  118.                     if ( n < 0xcc ) {
  119.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8;
  120.                 } else {
  121.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8 | ( n - 0xcc ) * 5;
  122.                 }
  123.                     
  124.                     gPalette[n] = 0;
  125.                     bPalette[n] = 0;
  126.                 }
  127.         colorTr = new ColorTransform(1111, -8, -8, -8);
  128.                 
  129.                 var timer:Timer = new Timer( 50000 );
  130.                 timer.addEventListener( TimerEvent.TIMER,
  131.                     function( e:TimerEvent ):void {
  132.                         change();
  133.                     }
  134.                 );
  135.                 timer.start();
  136.           }
  137.     // 描画、マウスの判定を後で追加予定
  138.     public function draw(mouseX: Number, mouseY: Number): void
  139.     {
  140.         var p: Particle = particles;
  141.         var col: uint;
  142.         
  143.         buf.colorTransform(buf.rect, colorTr);
  144.         while ((p = p.next) != null)
  145.         {
  146.             col = forceMap.getPixel(p.x >> 1, p.y >> 1);
  147.             p.x += (p.vx = p.vx * 0.98 + (( col >> 16 & 0xff)-128) * 0.004);
  148.             p.y += (p.vy = p.vy * 0.98 + (( col >> 8 & 0xff)-128) * 0.004);
  149.             if (p.x < 0) p.x += w;
  150.             else if (p.x >= w) p.x -= w;
  151.             if (p.y < 0) p.y += h;
  152.             else if (p.y >= h) p.y -= h;
  153.             buf.setPixel(p.x >> 0, p.y >> 0, color);
  154.         }
  155.                 bmpData.lock();
  156.                 bmpData.applyFilter( buf, buf.rect, buf.rect.topLeft, bf );
  157.                 bmpData.paletteMap( bmpData, bmpData.rect, bmpData.rect.topLeft, rPalette, gPalette, bPalette );
  158.                 bmpData.unlock();
  159.     }
  160.     
  161.     public function change(): void
  162.     {
  163.         forceMap.perlinNoise(mw, mh, 4, Math.random() * 0xFFFF, falsetrue7);
  164.     }
  165.     
  166.     public function resize(w: Number, h: Number): void
  167.     {
  168.         this.w = w;
  169.         this.h = h;
  170.         if (bmpData) 
  171.         {
  172.             bmpData.dispose();
  173.         }
  174.         bmpData = new BitmapData(w, h, false, 0x00000000);
  175.         view.bitmapData = bmpData;
  176.     }
  177. }
  178. class Particle
  179. {
  180.     public var x: Number = 0;
  181.     public var y: Number = 0;
  182.     public var vx: Number = 0;
  183.     public var vy: Number = 0;
  184.     public var next: Particle;
  185.     
  186.     public function Particle()
  187.     {
  188.         
  189.     }
  190. }
noswf
  1. // forked from munegon's 炎上シマスタ
  2. // forked from beinteractive's forked from: 10万個ぱーてぃくる - 軽く高速化
  3. // forked from bkzen's 10万個ぱーてぃくる
  4. package  
  5. {
  6.     import flash.display.Sprite;
  7.     import flash.display.StageAlign;
  8.     import flash.display.StageScaleMode;
  9.     import flash.events.Event;
  10.     import flash.events.MouseEvent;
  11.     import net.hires.debug.Stats;
  12.     
  13.     /**
  14.      * なんかいっぱい動かすテスト
  15.      * 洗濯機みたいになってます。
  16.      * @author jc at bk-zen.com
  17.      */
  18.     [SWF(backgroundColor = "0x000000", frameRate = "30")]
  19.     public class Test3 extends Sprite
  20.     {
  21.         protected const NUM_OF_PARTICLES: int = 100000;
  22.         private var main: TestMain;
  23.         
  24.         public function Test3() 
  25.         {
  26.             if (stage) init();
  27.             else addEventListener(Event.ADDED_TO_STAGE, init);
  28.         }
  29.         
  30.         private function init(e:Event = null):void 
  31.         {
  32.             removeEventListener(Event.ADDED_TO_STAGE, init);
  33.             //
  34.             main = new TestMain(stage.stageWidth, stage.stageHeight, NUM_OF_PARTICLES);
  35.             addChild(main.view);
  36.             addChild(new Stats());
  37.             stage.scaleMode = StageScaleMode.NO_SCALE;
  38.             stage.align = StageAlign.TOP_LEFT;
  39.             stage.addEventListener(Event.RESIZE, onResize);
  40.             stage.addEventListener(MouseEvent.CLICK, onClick);
  41.             addEventListener(Event.ENTER_FRAME, onEnter);
  42.             
  43.         }
  44.         
  45.         private function onClick(e:MouseEvent):void 
  46.         {
  47.             main.change();
  48.         }
  49.         
  50.         private function onEnter(e:Event):void 
  51.         {
  52.             main.draw(mouseX, mouseY);
  53.         }
  54.         // りサイズ (未実装)
  55.         private function onResize(e:Event):void 
  56.         {
  57.             main.resize(stage.stageWidth, stage.stageHeight);
  58.         }
  59.     }
  60. }
  61. import flash.display.Bitmap;
  62. import flash.display.BitmapData;
  63. import flash.geom.ColorTransform;
  64. import flash.geom.Point;
  65. import flash.utils.ByteArray;
  66. import flash.utils.Timer;
  67. import flash.events.TimerEvent;
  68. import flash.filters.BlurFilter;
  69. class TestMain
  70. {
  71.     private var w: int;
  72.     private var h: int;
  73.     private var mw: int;
  74.     private var mh: int;
  75.     public var view: Bitmap;
  76.     private var bmpData: BitmapData;
  77.         private var buf: BitmapData;
  78.     private var forceMap: BitmapData;
  79.     private var randomSeed: int;
  80.     private var particles: Particle;
  81.         private var bf: BlurFilter;
  82.         private var rPalette: Array;
  83.         private var gPalette: Array;
  84.         private var bPalette: Array;
  85.     private var num: int;
  86.     private var color: uint = 0xFFFFFF;
  87.     private var count: int = 0;
  88.     private var colorTr: ColorTransform;
  89.     
  90.     public function TestMain(w: int, h: int, numOfParticles: int)
  91.     {
  92.         this.w = w;
  93.         mw = w >> 1;
  94.         this.h = h;
  95.         mh = h >> 1;
  96.         bmpData = new BitmapData(w, h, false, 0x00000000);
  97.                 buf = bmpData.clone();
  98.         forceMap = new BitmapData(mw, mh, false);
  99.         forceMap.perlinNoise(mw >> 1, mh >> 14, Math.random() * 0xFFFF, falsetrue3);
  100.         view = new Bitmap(bmpData);
  101.                 bf = new BlurFilter( 16163 );
  102.                 rPalette = new Array256 );
  103.                 gPalette = new Array256 );
  104.                 bPalette = new Array256 );
  105.         num = numOfParticles;
  106.         var i: int;
  107.         var prev: Particle = particles = new Particle();
  108.         var p: Particle;
  109.         while (++i <= num)
  110.         {
  111.             p = new Particle();
  112.             p.x = Math.random() * w;
  113.             p.y = Math.random() * h;
  114.             prev.next = p;
  115.             prev = p;
  116.         }
  117.                 for ( var n:int = 0; n <= 0xff; ++n ) {
  118.                     if ( n < 0xcc ) {
  119.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8;
  120.                 } else {
  121.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8 | ( n - 0xcc ) * 5;
  122.                 }
  123.                     
  124.                     gPalette[n] = 0;
  125.                     bPalette[n] = 0;
  126.                 }
  127.         colorTr = new ColorTransform(1111, -8, -8, -8);
  128.                 
  129.                 var timer:Timer = new Timer( 50000 );
  130.                 timer.addEventListener( TimerEvent.TIMER,
  131.                     function( e:TimerEvent ):void {
  132.                         change();
  133.                     }
  134.                 );
  135.                 timer.start();
  136.           }
  137.     // 描画、マウスの判定を後で追加予定
  138.     public function draw(mouseX: Number, mouseY: Number): void
  139.     {
  140.         var p: Particle = particles;
  141.         var col: uint;
  142.         
  143.         buf.colorTransform(buf.rect, colorTr);
  144.         while ((p = p.next) != null)
  145.         {
  146.             col = forceMap.getPixel(p.x >> 1, p.y >> 1);
  147.             p.x += (p.vx = p.vx * 0.98 + (( col >> 16 & 0xff)-128) * 0.004);
  148.             p.y += (p.vy = p.vy * 0.98 + (( col >> 8 & 0xff)-128) * 0.004);
  149.             if (p.x < 0) p.x += w;
  150.             else if (p.x >= w) p.x -= w;
  151.             if (p.y < 0) p.y += h;
  152.             else if (p.y >= h) p.y -= h;
  153.             buf.setPixel(p.x >> 0, p.y >> 0, color);
  154.         }
  155.                 bmpData.lock();
  156.                 bmpData.applyFilter( buf, buf.rect, buf.rect.topLeft, bf );
  157.                 bmpData.paletteMap( bmpData, bmpData.rect, bmpData.rect.topLeft, rPalette, gPalette, bPalette );
  158.                 bmpData.unlock();
  159.     }
  160.     
  161.     public function change(): void
  162.     {
  163.         forceMap.perlinNoise(mw, mh, 4, Math.random() * 0xFFFF, falsetrue7);
  164.     }
  165.     
  166.     public function resize(w: Number, h: Number): void
  167.     {
  168.         this.w = w;
  169.         this.h = h;
  170.         if (bmpData) 
  171.         {
  172.             bmpData.dispose();
  173.         }
  174.         bmpData = new BitmapData(w, h, false, 0x00000000);
  175.         view.bitmapData = bmpData;
  176.     }
  177. }
  178. class Particle
  179. {
  180.     public var x: Number = 0;
  181.     public var y: Number = 0;
  182.     public var vx: Number = 0;
  183.     public var vy: Number = 0;
  184.     public var next: Particle;
  185.     
  186.     public function Particle()
  187.     {
  188.         
  189.     }
  190. }
noswf
  1. // forked from munegon's 炎上シマスタ
  2. // forked from beinteractive's forked from: 10万個ぱーてぃくる - 軽く高速化
  3. // forked from bkzen's 10万個ぱーてぃくる
  4. package  
  5. {
  6.     import flash.display.Sprite;
  7.     import flash.display.StageAlign;
  8.     import flash.display.StageScaleMode;
  9.     import flash.events.Event;
  10.     import flash.events.MouseEvent;
  11.     import net.hires.debug.Stats;
  12.     
  13.     /**
  14.      * なんかいっぱい動かすテスト
  15.      * 洗濯機みたいになってます。
  16.      * @author jc at bk-zen.com
  17.      */
  18.     [SWF(backgroundColor = "0x000000", frameRate = "30")]
  19.     public class Test3 extends Sprite
  20.     {
  21.         protected const NUM_OF_PARTICLES: int = 100000;
  22.         private var main: TestMain;
  23.         
  24.         public function Test3() 
  25.         {
  26.             if (stage) init();
  27.             else addEventListener(Event.ADDED_TO_STAGE, init);
  28.         }
  29.         
  30.         private function init(e:Event = null):void 
  31.         {
  32.             removeEventListener(Event.ADDED_TO_STAGE, init);
  33.             //
  34.             main = new TestMain(stage.stageWidth, stage.stageHeight, NUM_OF_PARTICLES);
  35.             addChild(main.view);
  36.             addChild(new Stats());
  37.             stage.scaleMode = StageScaleMode.NO_SCALE;
  38.             stage.align = StageAlign.TOP_LEFT;
  39.             stage.addEventListener(Event.RESIZE, onResize);
  40.             stage.addEventListener(MouseEvent.CLICK, onClick);
  41.             addEventListener(Event.ENTER_FRAME, onEnter);
  42.             
  43.         }
  44.         
  45.         private function onClick(e:MouseEvent):void 
  46.         {
  47.             main.change();
  48.         }
  49.         
  50.         private function onEnter(e:Event):void 
  51.         {
  52.             main.draw(mouseX, mouseY);
  53.         }
  54.         // りサイズ (未実装)
  55.         private function onResize(e:Event):void 
  56.         {
  57.             main.resize(stage.stageWidth, stage.stageHeight);
  58.         }
  59.     }
  60. }
  61. import flash.display.Bitmap;
  62. import flash.display.BitmapData;
  63. import flash.geom.ColorTransform;
  64. import flash.geom.Point;
  65. import flash.utils.ByteArray;
  66. import flash.utils.Timer;
  67. import flash.events.TimerEvent;
  68. import flash.filters.BlurFilter;
  69. class TestMain
  70. {
  71.     private var w: int;
  72.     private var h: int;
  73.     private var mw: int;
  74.     private var mh: int;
  75.     public var view: Bitmap;
  76.     private var bmpData: BitmapData;
  77.         private var buf: BitmapData;
  78.     private var forceMap: BitmapData;
  79.     private var randomSeed: int;
  80.     private var particles: Particle;
  81.         private var bf: BlurFilter;
  82.         private var rPalette: Array;
  83.         private var gPalette: Array;
  84.         private var bPalette: Array;
  85.     private var num: int;
  86.     private var color: uint = 0xFFFFFF;
  87.     private var count: int = 0;
  88.     private var colorTr: ColorTransform;
  89.     
  90.     public function TestMain(w: int, h: int, numOfParticles: int)
  91.     {
  92.         this.w = w;
  93.         mw = w >> 1;
  94.         this.h = h;
  95.         mh = h >> 1;
  96.         bmpData = new BitmapData(w, h, false, 0x00000000);
  97.                 buf = bmpData.clone();
  98.         forceMap = new BitmapData(mw, mh, false);
  99.         forceMap.perlinNoise(mw >> 1, mh >> 14, Math.random() * 0xFFFF, falsetrue3);
  100.         view = new Bitmap(bmpData);
  101.                 bf = new BlurFilter( 16163 );
  102.                 rPalette = new Array256 );
  103.                 gPalette = new Array256 );
  104.                 bPalette = new Array256 );
  105.         num = numOfParticles;
  106.         var i: int;
  107.         var prev: Particle = particles = new Particle();
  108.         var p: Particle;
  109.         while (++i <= num)
  110.         {
  111.             p = new Particle();
  112.             p.x = Math.random() * w;
  113.             p.y = Math.random() * h;
  114.             prev.next = p;
  115.             prev = p;
  116.         }
  117.                 for ( var n:int = 0; n <= 0xff; ++n ) {
  118.                     if ( n < 0xcc ) {
  119.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8;
  120.                 } else {
  121.                     rPalette[n] = 0xff000000 | Math.min( 1.5*n, 0xff ) << 16 | Math.min( 1.2*n, 0xff ) << 8 | ( n - 0xcc ) * 5;
  122.                 }
  123.                     
  124.                     gPalette[n] = 0;
  125.                     bPalette[n] = 0;
  126.                 }
  127.         colorTr = new ColorTransform(1111, -8, -8, -8);
  128.                 
  129.                 var timer:Timer = new Timer( 50000 );
  130.                 timer.addEventListener( TimerEvent.TIMER,
  131.                     function( e:TimerEvent ):void {
  132.                         change();
  133.                     }
  134.                 );
  135.                 timer.start();
  136.           }
  137.     // 描画、マウスの判定を後で追加予定
  138.     public function draw(mouseX: Number, mouseY: Number): void
  139.     {
  140.         var p: Particle = particles;
  141.         var col: uint;
  142.         
  143.         buf.colorTransform(buf.rect, colorTr);
  144.         while ((p = p.next) != null)
  145.         {
  146.             col = forceMap.getPixel(p.x >> 1, p.y >> 1);
  147.             p.x += (p.vx = p.vx * 0.98 + (( col >> 16 & 0xff)-128) * 0.004);
  148.             p.y += (p.vy = p.vy * 0.98 + (( col >> 8 & 0xff)-128) * 0.004);
  149.             if (p.x < 0) p.x += w;
  150.             else if (p.x >= w) p.x -= w;
  151.             if (p.y < 0) p.y += h;
  152.             else if (p.y >= h) p.y -= h;
  153.             buf.setPixel(p.x >> 0, p.y >> 0, color);
  154.         }
  155.                 bmpData.lock();
  156.                 bmpData.applyFilter( buf, buf.rect, buf.rect.topLeft, bf );
  157.                 bmpData.paletteMap( bmpData, bmpData.rect, bmpData.rect.topLeft, rPalette, gPalette, bPalette );
  158.                 bmpData.unlock();
  159.     }
  160.     
  161.     public function change(): void
  162.     {
  163.         forceMap.perlinNoise(mw, mh, 4, Math.random() * 0xFFFF, falsetrue7);
  164.     }
  165.     
  166.     public function resize(w: Number, h: Number): void
  167.     {
  168.         this.w = w;
  169.         this.h = h;
  170.         if (bmpData) 
  171.         {
  172.             bmpData.dispose();
  173.         }
  174.         bmpData = new BitmapData(w, h, false, 0x00000000);
  175.         view.bitmapData = bmpData;
  176.     }
  177. }
  178. class Particle
  179. {
  180.     public var x: Number = 0;
  181.     public var y: Number = 0;
  182.     public var vx: Number = 0;
  183.     public var vy: Number = 0;
  184.     public var next: Particle;
  185.     
  186.     public function Particle()
  187.     {
  188.         
  189.     }
  190. }
noswf
Get Adobe Flash Player