Skip to content

Commit

Permalink
add rgb values for current track vibrancy
Browse files Browse the repository at this point in the history
  • Loading branch information
twnlink committed Jan 29, 2024
1 parent 9b017b7 commit b02ecc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/api/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,25 @@ export const parseManifest = (manifest) => {

export const getMediaURLFromID = (id, path = "/1280x1280.jpg") =>
"https://resources.tidal.com/images/" + id.split("-").join("/") + path;


export function convertHexToRGB(h) {
let r = 0;
let g = 0;
let b = 0;

// 3 digits
if (h.length === 4) {
r = Number('0x' + h[1] + h[1]);
g = Number('0x' + h[2] + h[2]);
b = Number('0x' + h[3] + h[3]);

// 6 digits
} else if (h.length === 7) {
r = Number('0x' + h[1] + h[2]);
g = Number('0x' + h[3] + h[4]);
b = Number('0x' + h[5] + h[6]);
}

return `${r}, ${g}, ${b}`
}
2 changes: 1 addition & 1 deletion src/windowObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ try {

if (!vibrantColor) return;

vibrantColorStyle(`:root{--track-vibrant-color:${vibrantColor}}`);
vibrantColorStyle(`:root{--track-vibrant-color:${vibrantColor};--track-vibrant-color-rgb:${utils.convertHexToRGB(vibrantColor)}}`);
});
} catch {}

Expand Down

0 comments on commit b02ecc6

Please sign in to comment.