-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
76 lines (71 loc) · 2.18 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hue Map Palettes</title>
<meta name="description" content="Interpolate gradients based on common palettes.">
<meta name="keywords" content="viridis, color, hue, interpolate, hex, rgb, inferno, magma, plasma, matplotlib, seaborn, gradient, generate, scale, plot, graph">
<style>
:root {
color-scheme: light dark;
}
body {
font-family: sans-serif;
margin: 1em;
}
main {
display: grid;
grid-template-columns: 1fr auto;
gap: .4em 1em;
align-items: center;
margin-block: 1.5em;
}
main > div {
height: 2em;
display: flex;
}
main > div div {
flex: 1;
}
main label {
font-family: monospace;
}
</style>
</head>
<body>
<h1>Hue Map Palettes</h1>
<label>
Steps:
<input type="range" min="1" value="50">
<output></output>
</label>
<main></main>
<footer><a href="https://github.com/giraugh/hue-map">Visit the GitHub →</a></footer>
<script type="module">
import { createPalette, maps } from 'hue-map'
const main = document.querySelector('main')
const stepsInput = document.querySelector('input')
const stepsOutput = document.querySelector('output')
const generatePreviews = () => {
main.innerHTML = ''
const steps = Number(stepsInput.value)
stepsOutput.innerHTML = steps
Object.keys(maps).forEach(map => {
const swatch = document.createElement('div')
const label = document.createElement('label')
const palette = createPalette({ map, steps })
swatch.append(...palette.format().map(hex => {
const color = document.createElement('div')
color.style.background = hex
return color
}))
label.append(document.createTextNode(map))
main.append(swatch, label)
})
}
stepsInput.addEventListener('input', generatePreviews)
generatePreviews()
</script>
</body>
</html>