Add trippy beat chars

master
Will Toohey 9 years ago
parent f5524f3f48
commit c1516c3e3b
  1. 27
      src/js/HuesCanvas.js
  2. 10
      src/js/HuesCore.js
  3. 2
      src/js/HuesInfo.js
  4. 2
      src/js/HuesUI.js

@ -58,6 +58,7 @@ function HuesCanvas(root, audioContext, core) {
// trippy mode // trippy mode
this.trippyStart = [0, 0]; // x, y this.trippyStart = [0, 0]; // x, y
this.trippyRadii = [0, 0]; // x, y this.trippyRadii = [0, 0]; // x, y
// force trippy mode
this.trippyOn = false; this.trippyOn = false;
this.trippyRadius = 0; this.trippyRadius = 0;
@ -195,7 +196,7 @@ HuesCanvas.prototype.redraw = function() {
} }
} }
if(this.trippyOn && (this.trippyStart[0] || this.trippyStart[1])) { if(this.trippyStart[0] || this.trippyStart[1]) {
// x blur moves inwards from the corners, y comes out // x blur moves inwards from the corners, y comes out
// So the base colour is inverted for y, normal for x // So the base colour is inverted for y, normal for x
// Thus if the y start is more recent, we invert // Thus if the y start is more recent, we invert
@ -301,7 +302,7 @@ HuesCanvas.prototype.animationLoop = function() {
else else
this.core.blurUpdated(0, dist); this.core.blurUpdated(0, dist);
} }
if(this.trippyOn && (this.trippyStart[0] || this.trippyStart[1])) { if(this.trippyStart[0] || this.trippyStart[1]) {
for(let i = 0; i < 2; i++) { for(let i = 0; i < 2; i++) {
this.trippyRadii[i] = Math.floor((this.audio.currentTime - this.trippyStart[i]) * this.trippyRadius) * 2; this.trippyRadii[i] = Math.floor((this.audio.currentTime - this.trippyStart[i]) * this.trippyRadius) * 2;
if(this.trippyRadii[i] > this.trippyRadius) { if(this.trippyRadii[i] > this.trippyRadius) {
@ -458,7 +459,8 @@ HuesCanvas.prototype.mixColours = function(percent) {
HuesCanvas.prototype.doXBlur = function() { HuesCanvas.prototype.doXBlur = function() {
this.blurStart = this.audio.currentTime; this.blurStart = this.audio.currentTime;
this.trippyStart[0] = this.blurStart; if(this.trippyOn)
this.trippyStart[0] = this.blurStart;
this.blurDistance = this.blurAmount; this.blurDistance = this.blurAmount;
this.xBlur = true; this.xBlur = true;
this.yBlur = false; this.yBlur = false;
@ -467,13 +469,30 @@ HuesCanvas.prototype.doXBlur = function() {
HuesCanvas.prototype.doYBlur = function() { HuesCanvas.prototype.doYBlur = function() {
this.blurStart = this.audio.currentTime; this.blurStart = this.audio.currentTime;
this.trippyStart[1] = this.blurStart; if(this.trippyOn)
this.trippyStart[1] = this.blurStart;
this.blurDistance = this.blurAmount; this.blurDistance = this.blurAmount;
this.xBlur = false; this.xBlur = false;
this.yBlur = true; this.yBlur = true;
this.needsRedraw = true; this.needsRedraw = true;
}; };
HuesCanvas.prototype.doTrippyX = function() {
let saveTrippy = this.trippyOn;
// force trippy
this.trippyOn = true;
this.doXBlur();
this.trippyOn = saveTrippy;
}
HuesCanvas.prototype.doTrippyY = function() {
let saveTrippy = this.trippyOn;
// force trippy
this.trippyOn = true;
this.doYBlur();
this.trippyOn = saveTrippy;
}
HuesCanvas.prototype.setBlurDecay = function(decay) { HuesCanvas.prototype.setBlurDecay = function(decay) {
this.blurDecay = {"slow" : 7.8, "medium" : 14.1, "fast" : 20.8, "faster!" : 28.7}[decay]; this.blurDecay = {"slow" : 7.8, "medium" : 14.1, "fast" : 20.8, "faster!" : 28.7}[decay];
}; };

@ -123,7 +123,7 @@ function HuesCore(defaults) {
this.uiArray = []; this.uiArray = [];
// What's our root element? // What's our root element?
this.root = null;; this.root = null;
if(!defaults.root) { if(!defaults.root) {
this.root = document.body; this.root = document.body;
} else if(typeof defaults.root === "string") { } else if(typeof defaults.root === "string") {
@ -729,6 +729,14 @@ HuesCore.prototype.beater = function(beat) {
case 'o': case 'o':
this.renderer.doXBlur(); this.renderer.doXBlur();
break; break;
case '<':
case '>':
this.renderer.doTrippyX();
break;
case '(':
case ')':
this.renderer.doTrippyY();
break;
case '+': case '+':
this.renderer.doXBlur(); this.renderer.doXBlur();
this.renderer.doBlackout(); this.renderer.doBlackout();

@ -36,6 +36,8 @@ let beatGlossary = [
"* Image only", "* Image only",
"X Vertical blur only", "X Vertical blur only",
"O Horizontal blur only", "O Horizontal blur only",
">/< Trippy vertical blur",
"(/) Trippy horizontal blur",
"~ Fade color", "~ Fade color",
"= Fade and change image", "= Fade and change image",
"i Invert all colours", "i Invert all colours",

@ -444,7 +444,7 @@ MinimalUI.prototype.initUI = function() {
this.container.removeChild(this.beatBar); this.container.removeChild(this.beatBar);
this.container.innerHTML = ""; this.container.innerHTML = "";
this.container.appendChild(this.beatBar); this.container.appendChild(this.beatBar);
} };
function WeedUI(parent, name) { function WeedUI(parent, name) {
RetroUI.call(this, parent, name ? name : "WeedUI"); RetroUI.call(this, parent, name ? name : "WeedUI");

Loading…
Cancel
Save