Fix colour fades

serial
William Toohey 10 years ago
parent b6682c948f
commit 09cb33f3cb
  1. 13
      js/HuesCanvas.js
  2. 13
      js/HuesCore.js

@ -229,9 +229,13 @@ HuesCanvas.prototype.setImage = function(image) {
} }
} }
HuesCanvas.prototype.setColour = function(colour) { HuesCanvas.prototype.setColour = function(colour, isFade) {
this.stopFade(); if(isFade) {
this.colour = colour; this.newColour = colour;
} else {
this.stopFade();
this.colour = colour;
}
this.needsRedraw = true; this.needsRedraw = true;
} }
@ -268,12 +272,11 @@ HuesCanvas.prototype.doShortBlackout = function(beatTime) {
this.blackoutStart = 0; this.blackoutStart = 0;
} }
HuesCanvas.prototype.doColourFade = function(length, newColour) { HuesCanvas.prototype.doColourFade = function(length) {
this.colourFade = true; this.colourFade = true;
this.colourFadeLength = length; this.colourFadeLength = length;
this.colourFadeStart = this.aContext.currentTime; this.colourFadeStart = this.aContext.currentTime;
this.oldColour = this.colour; this.oldColour = this.colour;
this.newColour = newColour;
} }
HuesCanvas.prototype.stopFade = function() { HuesCanvas.prototype.stopFade = function() {

@ -325,14 +325,14 @@ HuesCore.prototype.randomColourIndex = function() {
return index; return index;
} }
HuesCore.prototype.randomColour = function() { HuesCore.prototype.randomColour = function(isFade) {
var index=this.randomColourIndex(); var index=this.randomColourIndex();
this.setColour(index); this.setColour(index, isFade);
} }
HuesCore.prototype.setColour = function(index) { HuesCore.prototype.setColour = function(index, isFade) {
this.colourIndex = index; this.colourIndex = index;
this.renderer.setColour(this.colours[this.colourIndex].c); this.renderer.setColour(this.colours[this.colourIndex].c, isFade);
this.userInterface.setColourText(); this.userInterface.setColourText();
} }
@ -391,8 +391,9 @@ HuesCore.prototype.beater = function(beat) {
break; break;
} }
} }
this.stopFade(); this.renderer.stopFade();
this.startFade(fadeLen * this.beatLength); this.renderer.doColourFade(fadeLen * this.beatLength);
this.randomColour(true);
break; break;
} }
if ([".", "+", "|", "¤"].indexOf(beat) == -1) { if ([".", "+", "|", "¤"].indexOf(beat) == -1) {

Loading…
Cancel
Save