Soap bubbles - Raphaël eye candy

Thegor - The Graphic Operation Runner

by andersand

HTML

<div id="gfx"></div>

JavaScript

/**
 * Soap bubbles - Raphaël eye candy.
 *
 * Somewhat configurable Graphic Operation Runner (GOR). Yeah that name will have to do.
 *
 * TBD: [configurability] features only random operation selection, make configurable 
 * TBD: [configurability] features only random element removal, make configurable 
 *
 * @author [email protected]
 */
var andersand = {
    config : {
        name : "Soap bubbles",
        credits : "andersand 2011",
        selection : ["floating soap bubbles"],
        width : 600,
        height : 600,
        initialWait : 2000,
        interval : 50,
        repetitions : 100,
        maxSimultaneousElements : 50,
        doneOperation : function(index, element) {
            (function(ix) {
                var config = andersand.config,
                    rnd2 = andersand.rnd2;
                setTimeout(function() {
                    element.stop();
                    var a = element.attrs;
                    var rndColor = "rgb(_,_,_)".replace(/_/g, function() {return rnd2(128,255);});
                    element.attr({fill : rndColor, stroke : "#000"});
                    element.animate({
                        "50%" : {r : 5},
                        "60%" : {cy : config.height-5},
                        "100%": {cx : (a.cx < config.width/2 ? -5 : config.width+5)}
                    }, 4000);
                }, ix * 200);
            })(index);
        }
    },
    elementStack : [],
    rnd : function(max) {
        return Math.round(Math.random()*max);
    },
    rnd2 : function(min, max) {
        return min+andersand.rnd(max-min);
    },
    rnd3 : function(min, max) {
        return min+Math.random()*max;
    },
    operations : function(paper) {
        var operations = [];
        var config = andersand.config;
        var rnd = andersand.rnd,
            rnd2 = andersand.rnd2;

        operations.push({
            name : "floating soap bubbles",
            fun : function(i) { 
                var r =...