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

MidPoint Requiem

+ midpoint never gets old !
+ could use this one for a sky texture maybe
Get Adobe Flash player
by FLASHMAFIA 10 Sep 2013
  • Forked from FLASHMAFIA's MidPoint Angelo
  • Diff: 111
  • Related works: 5
  • Talk

    peko_ at 11 Sep 2013 07:06
    not really optimised dear the mvt hopefully you'll do better next time keep trying
    FLASHMAFIA at 12 Sep 2013 03:53
    lol
    FLASHMAFIA at 12 Sep 2013 03:53
    (noob)
    peko_ at 12 Sep 2013 07:19
    :*
    WLAD at 12 Sep 2013 19:24
    @peko , For a second there i though you just lost fear offending people over the internet. But since you accepted your rank (noob). I'm well satisfied, and the need to offend you has just disappeared.
    FLASHMAFIA at 13 Sep 2013 04:40
    haha it's cool peko is just a friend of mine doing a bad joke .... ( a noob joke! ) ; >
    PESakaTFM at 13 Sep 2013 20:35
    The only optimization I can see that would be worth doing (if needed, which it is not) would be to recycle the variables in oef() rather than creating new vars every time... mainly in the while loop. But, I'm not sure if that would make a difference. This looks pretty good to me. I like it.

    Tags

    Embed
/**
 * Copyright FLASHMAFIA ( http://wonderfl.net/user/FLASHMAFIA )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/zGSk
 */

package {
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.filters.BitmapFilterQuality;
    import flash.filters.BlurFilter;
    import flash.geom.Point;

    [SWF(width = '465', height = '465')]
    public class MPAngelo2 extends Sprite
    {
        private const NUM_P : uint = 222222;
        /* */
        private var p__ : Particle;
        private var buf : Vector.<uint>;
        private var bmd : BitmapData;
        private var ofscr : BitmapData;
        private var blur : BlurFilter;
        private var dstp : Point;
        private var fcnt : int;

        public function MPAngelo2()
        {
            stage.stageFocusRect = mouseEnabled = mouseChildren = tabEnabled = tabChildren = false;
            stage.scaleMode = 'noScale';
            stage.align = 'TL';
            stage.quality = 'low';
            stage.frameRate = 64;
            opaqueBackground = 0x0;

            var p : Particle = p__ = new Particle();

            var n : uint = NUM_P;
            while (--n != 0)
            {
                var f : Number = n / NUM_P;
                var a : Number = f * (Math.PI * 2);
                var aa : Number = (1 / f) * (Math.PI * 2);
                var fuz : Number = 0.85 + 0.15 * Math.random();

                p.x = p.dx = 256 + (2048 - (1024 * Math.cos(aa * fuz) * fuz)) * Math.cos(a * fuz);
                p.y = p.dy = 256 + (2048 - (1024 * Math.sin(aa * fuz) * fuz)) * Math.sin(a * fuz);

                if (f < 0.5)
                {
                    p.rr = 5;
                    p.gg = 3;
                    p.bb = 1;
                } 
                else
                {
                    p.rr = 1;
                    p.gg = 3;
                    p.bb = 5;
                }

                p = p.next = new Particle();
            }

            bmd = new BitmapData(512, 512, false, 0x0);
            ofscr = bmd.clone();
            buf = new Vector.<uint>(512 * 512, true);

            var bm : Bitmap = new Bitmap(bmd);
            bm.x = bm.y = (465 - 512) / 2;
            bm.opaqueBackground = 0x0;
            addChild(bm);

            blur = new BlurFilter(6, 8, BitmapFilterQuality.HIGH);
            dstp = new Point();

            stage.addEventListener(Event.ENTER_FRAME, oef);
        }

        private function oef(e : Event) : void
        {
            fcnt++;

            var t : Number = (fcnt & 131071) / 131072;

            var rx : Number = Math.cos(t);
            var ry : Number = Math.sin(t);

            ofscr.applyFilter(bmd, bmd.rect, dstp, blur);

            var buf : Vector.<uint> = ofscr.getVector(ofscr.rect);

            var p : Particle = p__;
            while (p != null)
            {
                var dx : int = p.dx - 256;
                var dy : int = p.dy - 256;

                p.dx = 256 + (rx * dx) - (ry * dy);
                p.dy = 256 + (rx * dy) + (ry * dx);

                p.x += (p.dx - p.x) >> 4;
                p.y += (p.dy - p.y) >> 7;

                var pos : uint = ((p.y & 511) << 9) + (p.x & 511);

                var c : uint = buf[pos];
                var r : uint = (c >> 16 & 0xFF) + p.rr;
                var g : uint = (c >> 8 & 0xFF) + p.gg;
                var b : uint = (c & 0xFF) + p.bb;

                if (r > 0xFF) r = 0xFF;
                if (g > 0xFF) g = 0xFF;
                if (b > 0xFF) b = 0xFF;

                buf[pos] = r << 16 | g << 8 | b;

                p = p.next;
            }

            bmd.setVector(bmd.rect, buf);
        }
    }
}

internal class Particle {
    public var next : Particle;
    public var rr : uint;
    public var gg : uint;
    public var bb : uint;
    public var x : int;
    public var y : int;
    public var dx : int;
    public var dy : int;
}