add comments

This commit is contained in:
Mylloon 2024-12-13 20:07:54 +01:00
parent edb36ed424
commit b1f5a775d9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -3,6 +3,10 @@ const Mode = {
Dark: 2,
};
/**
* Change the svg color theme based on the mode
* @param {Mode} mode
*/
const svgChangeTheme = (mode) => {
for (const item of document.getElementsByTagName("img")) {
if (!item.src.startsWith("data:image/svg+xml;base64,")) {
@ -10,12 +14,20 @@ const svgChangeTheme = (mode) => {
continue;
}
/** Convert to grayscale */
/**
* Convert to grayscale
* @param {{r: number, g: number, b: number}} color
* @returns Number between 0 and 255
*/
const colorToGrayscale = (color) => {
return 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;
};
/** Extract color using canvas2d */
/**
* Extract color using canvas2d
* @param {HTMLImageElement} image Image source
* @returns Colors represeting the image
*/
const extractColors = (image) => {
const canvas = document.createElement("canvas");
canvas.width = image.width;