Permalink
Browse files

removed hardcoded element

  • Loading branch information...
1 parent 2a8c244 commit 96259c552965478afc49afa4010a0a640e7722c7 @stuartmemo committed Oct 13, 2012
Showing with 5 additions and 11 deletions.
  1. +5 −11 wavy-jones.js
View
@@ -1,19 +1,18 @@
var WavyJones = function (context, elem) {
var analyser = context.createAnalyser();
+
analyser.width = document.getElementById(elem).offsetWidth;
analyser.height = document.getElementById(elem).offsetHeight;
analyser.lineColor = 'yellow';
- analyser.lineThickness = 1;
+ analyser.lineThickness = 5;
- var paper = Raphael('scope', analyser.width, analyser.height),
+ var paper = Raphael(elem, analyser.width, analyser.height),
oscLine = paper.path([['M', 0, analyser.height/2], ['L', analyser.width, analyser.height/2], 'Z']),
noDataPoints = 10,
freqData = new Uint8Array(analyser.frequencyBinCount);
oscLine.attr({stroke: analyser.lineColor, 'stroke-width': analyser.lineThickness});
- var firstGo = true;
-
var drawLine = function () {
analyser.getByteTimeDomainData(freqData);
@@ -33,19 +32,14 @@ var WavyJones = function (context, elem) {
graphStr += graphPoints[i];
}
- if (firstGo) {
- console.log(graphStr)
- firstGo = false;
- }
-
oscLine.attr('stroke', analyser.lineColor);
oscLine.attr('stroke-width', analyser.lineThickness);
oscLine.attr('path', graphStr);
setTimeout(drawLine, 100);
- }
+ };
drawLine();
- return analyser;
+ return analyser;
};

0 comments on commit 96259c5

Please sign in to comment.