-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
38 lines (37 loc) · 1.31 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
</head>
<body>
<img
crossorigin="Anonymous"
src="https://raw.githubusercontent.com/jsupa/crypto-icons/main/icons/xrp.png"
id="color-thief-img"
/>
<div id="color-thief-div">
<img
crossorigin="Anonymous"
src="https://raw.githubusercontent.com/jsupa/crypto-icons/main/icons/etc.png"
/>
<h1>Doge Color</h1>
</div>
<script src="./color-thief.min.js"></script>
<script>
window.addEventListener("load", function (event) {
const colorThief = new ColorThief();
const img = document.getElementById("color-thief-img");
const div = document.getElementById("color-thief-div");
const BgPalette = colorThief.getPalette(img, 0);
const ImgPalette = colorThief.getPalette(
div.getElementsByTagName("img")[0],
0
);
document.body.style.backgroundColor = `rgb(${BgPalette[0]})`;
div.getElementsByTagName(
"h1"
)[0].style.color = `rgb(${ImgPalette[0]})`;
});
</script>
</body>
</html>