diff --git a/src/mappings/numeric.js b/src/mappings/numeric.js index 609ea12..523ccaf 100644 --- a/src/mappings/numeric.js +++ b/src/mappings/numeric.js @@ -31,7 +31,6 @@ import VisUpdateRouter from "../visualization/VisUpdateRouter.js"; * @returns {{lower: number, upper: number, listener: VisUpdateRouter.visualizerRangedUpdateListener}} An object containing the lower and upper bounds for the range of a listener, which is also in the object. */ export function mapRangedAvgNumerical({ minVal, maxVal, lowerBin = undefined, upperBin, getter, setter, interpolator, visUpdateRouter, reversed = false }) { - console.log("mapping average numerical."); const rangedListener = { lower: lowerBin, upper: upperBin, @@ -72,7 +71,6 @@ export function mapRangedAvgNumerical({ minVal, maxVal, lowerBin = undefined, up * @returns {{bin: number, listener: VisUpdateRouter~visualizerBinUpdateListener}} The bin listener that was added. */ export function mapBinNumerical({ minVal, maxVal, bin, getter, setter, interpolator, visUpdateRouter, reversed = false }) { - console.log("mapping numerical..."); const listener = { bin: bin, listener: (timeDelta, amp) => { diff --git a/src/mappings/text.js b/src/mappings/text.js index d24e6c0..c1f6fa3 100644 --- a/src/mappings/text.js +++ b/src/mappings/text.js @@ -22,7 +22,7 @@ export function mapRgba({ element, color, lowerBin, visUpdateRouter, interpolato color = rgbaStr.indexOf(color); if (color < 0) throw new Error("Invalid color parameter provided."); const getter = () => { - if (!element.style.color) element.style.color = "rgb(0,0,255)"; + if (!element.style.color) element.style.color = "rgba(0, 0, 0, 255)"; return parseColor(element.style.color)[color]; }; const setter = (value) => { diff --git a/src/support/colors.js b/src/support/colors.js index aa5cdf2..20a8381 100644 --- a/src/support/colors.js +++ b/src/support/colors.js @@ -79,7 +79,7 @@ export function cssRgbToRgba(rgb) { */ export function rgbaToHexRgba(rgba) { const filler = (hex) => hex.length < 2 ? "0" + hex : hex; - return "#" + filler(rgba[0].toString(16)) + filler(rgba[1].toString(16)) + filler(rgba[2].toString(16)) + filler(rgba[3].toString(16)); + return "#" + filler(Math.round(rgba[0]).toString(16)) + filler(Math.round(rgba[1]).toString(16)) + filler(Math.round(rgba[2]).toString(16)) + filler(Math.round(rgba[3]).toString(16)); } diff --git a/src/visualization/VisUpdateRouter.js b/src/visualization/VisUpdateRouter.js index 8bb91e3..fde15c8 100644 --- a/src/visualization/VisUpdateRouter.js +++ b/src/visualization/VisUpdateRouter.js @@ -92,7 +92,6 @@ export default class VisUpdateRouter { * @returns {boolean} True if and only if the ranged listener was added successfully. */ addVisualizerRangedUpdateListener({ lower, upper, listener }) { - console.log("range update listener added."); const rangedListener = { lower: lower, upper: upper, diff --git a/src/visualization/Visualizer.js b/src/visualization/Visualizer.js index 6d41a19..74484ff 100644 --- a/src/visualization/Visualizer.js +++ b/src/visualization/Visualizer.js @@ -86,7 +86,6 @@ export default class Visualizer { * @returns {boolean} true if and only if the listener was successfully added. */ addUpdateListener(listener) { - console.log("visualizer received listener"); if (this.#updateListeners.includes(listener)); this.#updateListeners.push(listener); return true; diff --git a/tutorials/VisMusicPlayer.html b/tutorials/VisMusicPlayer.html index 1efe1b9..07f3eee 100644 --- a/tutorials/VisMusicPlayer.html +++ b/tutorials/VisMusicPlayer.html @@ -95,6 +95,27 @@ ask.mappings.dimensions.mapHeight(squareElemConf); +
+

Mapping Font Color

+

Now for a bit more of an eccentric mapping, you can map the color of a font to the music!

+
+
+ Hello world! +
+
+

+            const fontColorElem = document.getElementById("font-color-map-demo");
+            ask.mappings.text.mapRgba({ // Under mappings, the text module. We just want to map one of the RGBA color components...
+                element: fontColorElem, // The element to map (same as above examples).
+                color: "r", // Choose the red component.
+                lowerBin: 128, // All other values are what we've seen above.
+                upperBin: 160,
+                visUpdateRouter: player.visUpdateRouter,
+                interpolator: ask.support.easings.createEaseLinear(2.5)
+            });
+        
+
+ \ No newline at end of file