|
|
|
|
|
|
|
var HarmonicController = function() { |
|
|
|
|
|
|
|
|
|
|
|
this.cv; |
|
|
|
this.arrHarmonics = new Array(); |
|
|
|
this.startingFrequency = 100; |
|
|
|
|
|
|
|
var howmany = getQueryVariable('howmany'); |
|
|
|
var max = 256; var min = 4; |
|
var defaultNumber = 16; |
|
if (howmany > max) { |
|
howmany = max; |
|
} else if (howmany < min) { |
|
howmany = min; |
|
} else if (isNaN(howmany)) { |
|
howmany = defaultNumber; |
|
} else if (howmany == null) { |
|
howmany = defaultNumber; |
|
} |
|
this.harmonics = howmany; |
|
|
|
this.init(); |
|
|
|
} |
|
|
|
|
|
|
|
HarmonicController.prototype.init = function() { |
|
|
|
this.cv = ctx; |
|
|
|
|
|
for (var i = 0; i < this.harmonics; i++) { |
|
this.arrHarmonics[i] = new Harmonic(i, this); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
HarmonicController.prototype.begin = function() { |
|
} |
|
|
|
|
|
|
|
|
|
HarmonicController.prototype.upd = function() { |
|
|
|
|
|
for (var i = 0; i < this.harmonics; i++) { |
|
this.arrHarmonics[i].isATouchOverMe = false; |
|
this.arrHarmonics[i].upd(); |
|
} |
|
|
|
|
|
if (isMousePressing) { |
|
|
|
for (var j = 0; j < this.harmonics; j++) { |
|
this.arrHarmonics[j].checkIfATouchIsOverMe(xMouse, yMouse); |
|
} |
|
|
|
|
|
} else { |
|
|
|
var currentTouch; |
|
|
|
for (var i=0; i < currentTouches.length; i++) { |
|
currentTouch = currentTouches[i]; |
|
|
|
for (var j = 0; j < this.harmonics; j++) { |
|
this.arrHarmonics[j].checkIfATouchIsOverMe(currentTouch.pageX, currentTouch.pageY); |
|
} |
|
} |
|
} |
|
|
|
|
|
for (var i = 0; i < this.harmonics; i++) { |
|
this.arrHarmonics[i].checkIfIShouldBePlaying(); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
HarmonicController.prototype.updateSizeAndPosition = function() { |
|
|
|
for (var i = 0; i < this.harmonics; i++) { |
|
var h = this.arrHarmonics[i]; |
|
if (h) { |
|
h.updateSizeAndPosition(); |
|
} |
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
HarmonicController.prototype.mouseDown = function() { |
|
|
|
} |
|
|
|
|
|
|
|
HarmonicController.prototype.mouseUp = function() { |
|
|
|
} |
|
|
|
|