Fixed RGBA mapping and added to VisMusicPlayer tutorial.
This commit is contained in:
@@ -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) => {
|
||||
|
@@ -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) => {
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user