{"version":3,"file":"anim_ripple.min.js","sources":["../src/anim_ripple.js"],"sourcesContent":["/* jshint ignore:start */\ndefine(['jquery', 'core/log'], function ($, log) {\n\n    \"use strict\"; // jshint ;_;\n\n    log.debug('anim_ripple: initialising');\n\n    return {\n\n        analyser: null,\n        cvs: null,\n        cvsctx: null,\n        drawparams: {\n            rippleColor: '#0',\n            lineWidth: 2\n        },\n\n        //for making multiple instances\n        clone: function () {\n            return $.extend(true, {}, this);\n        },\n\n        //init\n        init: function (analyser, cvs) {\n            this.cvs = cvs;\n            this.cvsctx = cvs.getContext(\"2d\");\n            this.analyser = analyser;\n        },\n\n        setDrawParam: function (paramkey, paramvalue) {\n            this.drawparams[paramkey] = paramvalue;\n        },\n\n        clear: function () {\n            this.cvsctx.clearRect(0, 0, this.cvs.width, this.cvs.height);\n        },\n\n        start: function () {\n            this.analyser.core.fftSize = 2048;\n            var bufferLength = this.analyser.core.fftSize;\n            var dataArray = new Uint8Array(bufferLength);\n            var cwidth = this.cvs.width;\n            var cheight = this.cvs.height;\n            var canvasCtx = this.cvsctx;\n            var analyser = this.analyser;\n            this.clear();\n            var that = this;\n\n            var draw = function () {\n\n                var drawVisual = requestAnimationFrame(draw);\n\n                //cancel out if the theinterval is null\n                if (!analyser.theinterval) {\n                    return;\n                }\n\n                analyser.core.getByteTimeDomainData(dataArray);\n\n                //this fills grey, but its lame lets just leave it clear\n                //canvasCtx.fillStyle = 'rgb(200, 200, 200)';\n                canvasCtx.clearRect(0, 0, cwidth, cheight);\n\n                canvasCtx.lineWidth = that.drawparams.lineWidth;\n                canvasCtx.setLineDash([15, 5]);\n                canvasCtx.strokeStyle = that.drawparams.rippleColor;\n\n                canvasCtx.beginPath();\n\n                var recwidth = 100;\n                if (bufferLength > 0) {\n                    var stepsize = 1 + bufferLength / 5;\n                }\n\n\n                for (var i = 0; i < bufferLength; i = i + stepsize) {\n                    var v = dataArray[i] / 128.0;\n                    var y = v * (cheight - recwidth) / 4;\n                    var radius = recwidth / 2 + y\n                    canvasCtx.arc(cwidth / 2, cheight / 2, radius, 0, 2 * Math.PI);\n                }\n                canvasCtx.stroke();\n            };\n\n            draw();\n        }//END OF START\n    };//end of returned object\n});//total end\n"],"names":["define","$","log","debug","analyser","cvs","cvsctx","drawparams","rippleColor","lineWidth","clone","extend","this","init","getContext","setDrawParam","paramkey","paramvalue","clear","clearRect","width","height","start","core","fftSize","bufferLength","dataArray","Uint8Array","cwidth","cheight","canvasCtx","that","draw","requestAnimationFrame","theinterval","getByteTimeDomainData","setLineDash","strokeStyle","beginPath","stepsize","i","radius","recwidth","arc","Math","PI","stroke"],"mappings":"AACAA,mCAAO,CAAC,SAAU,aAAa,SAAUC,EAAGC,YAIxCA,IAAIC,MAAM,6BAEH,CAEHC,SAAU,KACVC,IAAK,KACLC,OAAQ,KACRC,WAAY,CACRC,YAAa,KACbC,UAAW,GAIfC,MAAO,kBACIT,EAAEU,QAAO,EAAM,GAAIC,OAI9BC,KAAM,SAAUT,SAAUC,UACjBA,IAAMA,SACNC,OAASD,IAAIS,WAAW,WACxBV,SAAWA,UAGpBW,aAAc,SAAUC,SAAUC,iBACzBV,WAAWS,UAAYC,YAGhCC,MAAO,gBACEZ,OAAOa,UAAU,EAAG,EAAGP,KAAKP,IAAIe,MAAOR,KAAKP,IAAIgB,SAGzDC,MAAO,gBACElB,SAASmB,KAAKC,QAAU,SACzBC,aAAeb,KAAKR,SAASmB,KAAKC,QAClCE,UAAY,IAAIC,WAAWF,cAC3BG,OAAShB,KAAKP,IAAIe,MAClBS,QAAUjB,KAAKP,IAAIgB,OACnBS,UAAYlB,KAAKN,OACjBF,SAAWQ,KAAKR,cACfc,YACDa,KAAOnB,KAEPoB,KAAO,WAEUC,sBAAsBD,SAGlC5B,SAAS8B,aAId9B,SAASmB,KAAKY,sBAAsBT,WAIpCI,UAAUX,UAAU,EAAG,EAAGS,OAAQC,SAElCC,UAAUrB,UAAYsB,KAAKxB,WAAWE,UACtCqB,UAAUM,YAAY,CAAC,GAAI,IAC3BN,UAAUO,YAAcN,KAAKxB,WAAWC,YAExCsB,UAAUQ,eAGNb,aAAe,MACXc,SAAW,EAAId,aAAe,MAIjC,IAAIe,EAAI,EAAGA,EAAIf,aAAce,GAAQD,SAAU,KAG5CE,OAASC,GAFLhB,UAAUc,GAAK,KACVX,QARF,KAQwB,EAEnCC,UAAUa,IAAIf,OAAS,EAAGC,QAAU,EAAGY,OAAQ,EAAG,EAAIG,KAAKC,IAE/Df,UAAUgB,WAGdd"}