In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

文字ぱーてぃくる

文字いっぱい!
画質はディフォルトの StageQuality.HIGH で
文字 1000個
@author paq
// forked from clockmaker's BitmapDataで配列に格納すると高速化するよ
// forked from clockmaker's 3D Flow Simulation with Field of Blur
// forked from clockmaker's 3D Flow Simulation
// forked from clockmaker's Interactive Liquid 10000
// forked from clockmaker's Liquid110000 By Vector
// forked from munegon's forked from: forked from: forked from: forked from: Liquid10000
// forked from Saqoosha's forked from: forked from: forked from: Liquid10000
// forked from nutsu's forked from: forked from: Liquid10000
// forked from nutsu's forked from: Liquid10000
// forked from zin0086's Liquid10000
package 
{
    /**
     * 文字いっぱい!
     * 画質はディフォルトの StageQuality.HIGH で
     * 文字 1000個
     * @author paq
     */
    import flash.display.*;
    import flash.geom.*;
    import flash.events.*;
    import flash.text.TextField;
    import flash.utils.*;
    import flash.geom.*;
    import net.hires.debug.Stats;
    
    [SWF(width="465", height="465", backgroundColor="0xFFFFFF")]
    public class Main extends Sprite {
        private const NUM_PARTICLE:uint = 1000;
        private const ROT_STEPS:int = 120;
        
        private var forceMap:BitmapData = new BitmapData( 233, 233, false, 0x000000 );
        private var randomSeed:uint = Math.floor( Math.random() * 0xFFFF );
        private var particleList:Vector.<TextParticle> = new Vector.<TextParticle>(NUM_PARTICLE, true);
        private var rect:Rectangle = new Rectangle( 0, 0, 465, 465 );
        private var seed:Number = Math.floor( Math.random() * 0xFFFF );
        private var offset:Array = [new Point(), new Point()];
        private var timer:Timer;
        private var world:Sprite = new Sprite();
        private var rotArr:Vector.<BitmapData> = new Vector.<BitmapData>(ROT_STEPS, true);
	
	[Embed(systemFont="serif", fontName="font", unicodeRange="U+0000-U+005A", mimeType="application/x-font")]
	private var font:Class;
	
        public function Main() {
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.frameRate = 60;
            
            addChild(world);
            
            // フォースマップの初期化をおこないます
            resetFunc();
            
            // ループ処理
            addEventListener( Event.ENTER_FRAME, loop );
            
            // 時間差でフォースマップと色変化の具合を変更しています
            var timer:Timer = new Timer(1000)
            timer.addEventListener(TimerEvent.TIMER, resetFunc);
            timer.start();
            
            // 文字をプレレンダリング
            var dummy:TextField = new TextField();
	    dummy.width = 20;
	    dummy.height = 20;
            dummy.htmlText = "<font face='font' size='20'>A</font>";
	    dummy.embedFonts = true;

            
            var matrix:Matrix;
            var i:int = ROT_STEPS;
            while (i--)
            {
                matrix = new Matrix();
                matrix.translate( -11, -11);
                matrix.rotate( ( 360 / ROT_STEPS * i )* Math.PI / 180);
                matrix.translate( 11, 11);
                rotArr[i] = new BitmapData(20, 20, true, 0x0);
                rotArr[i].draw(dummy, matrix);
            }
            
            // パーティクルを生成します
            for (i = 0; i < NUM_PARTICLE; i++) {
                var px:Number = Math.random() * 465;
                var py:Number = Math.random() * 465;
                particleList[i] = new TextParticle(px, py);
                world.addChild(particleList[i]);
            }
            
            // デバッグ用のスタッツを表示しています
            addChild(new Stats);
        }
        
        private function loop( e:Event ):void {
            
            var len:uint = NUM_PARTICLE;
            var col:Number;
            
            for (var i:uint = 0; i < len; i++) {
                
                var word:TextParticle = particleList[i];
                
                var oldX:Number = word.x;
                var oldY:Number = word.y;
                
                col = forceMap.getPixel( word.x >> 1, word.y >> 1);
                word.ax += ( (col      & 0xff) - 0x80 ) * .0005;
                word.ay += ( (col >> 8 & 0xff) - 0x80 ) * .0005;
                word.vx += word.ax;
                word.vy += word.ay;
                word.x += word.vx;
                word.y += word.vy;
                
                var _posX:Number = word.x;
                var _posY:Number = word.y;
                
                var rot:Number = - Math.atan2((_posX - oldX), (_posY - oldY)) * 180 / Math.PI + 90;
                var angle:int = rot / 360 * ROT_STEPS | 0;
                // Math.absの高速化ね
                angle = (angle ^ (angle >> 31)) - (angle >> 31);
                word.rot += (angle - word.rot) * 0.2;
                word.bitmapData = rotArr[word.rot];
                    
                word.ax *= .96;
                word.ay *= .96;
                word.vx *= .92;
                word.vy *= .92;
                
                // あと配置座標を整数化しておきます
                word.x = word.x | 0;
                word.y = word.y | 0;
                
                ( _posX > 465 ) ? word.x = 0 :
                    ( _posX < 0 ) ? word.x = 465 : 0;
                ( _posY > 465 ) ? word.y = 0 :
                    ( _posY < 0 ) ? word.y = 465 : 0;
            }
        }
        
        private function resetFunc(e:Event = null):void{
            forceMap.perlinNoise(117, 117, 3, seed, false, true, 6, false, offset);
            
            offset[0].x += 1.5;
            offset[1].y += 1;
            seed = Math.floor( Math.random() * 0xFFFFFF );
        }
    }
}

import flash.display.*;

class TextParticle extends Bitmap
{
    public var rot:int = 0;
    public var vx:Number = 0;
    public var vy:Number = 0;
    public var ax:Number = 0;
    public var ay:Number = 0;

    function TextParticle( x:Number, y:Number) {
        this.x = x;
        this.y = y;
    }
}