add comments
This commit is contained in:
parent
edb36ed424
commit
b1f5a775d9
1 changed files with 14 additions and 2 deletions
|
@ -3,6 +3,10 @@ const Mode = {
|
||||||
Dark: 2,
|
Dark: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the svg color theme based on the mode
|
||||||
|
* @param {Mode} mode
|
||||||
|
*/
|
||||||
const svgChangeTheme = (mode) => {
|
const svgChangeTheme = (mode) => {
|
||||||
for (const item of document.getElementsByTagName("img")) {
|
for (const item of document.getElementsByTagName("img")) {
|
||||||
if (!item.src.startsWith("data:image/svg+xml;base64,")) {
|
if (!item.src.startsWith("data:image/svg+xml;base64,")) {
|
||||||
|
@ -10,12 +14,20 @@ const svgChangeTheme = (mode) => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert to grayscale */
|
/**
|
||||||
|
* Convert to grayscale
|
||||||
|
* @param {{r: number, g: number, b: number}} color
|
||||||
|
* @returns Number between 0 and 255
|
||||||
|
*/
|
||||||
const colorToGrayscale = (color) => {
|
const colorToGrayscale = (color) => {
|
||||||
return 0.3 * color.r + 0.59 * color.g + 0.11 * color.b;
|
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 extractColors = (image) => {
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
canvas.width = image.width;
|
canvas.width = image.width;
|
||||||
|
|
Loading…
Reference in a new issue