forked from juxtopposed/color-gamuts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
272 lines (220 loc) · 7.91 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Color Gamut Test</title>
<script src="https://colorjs.io/dist/color.global.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="icon" type="image/png" href="/favicon.png">
<style>
@import url('https://fonts.googleapis.com/css?family=Martian%20Mono:200');
.row {
display: flex;
flex-direction: row;
margin-top: 1rem;
width: 100%;
}
.colors {
height: 100%;
}
.column {
display: flex;
flex-direction: column;
justify-content: space-between;
height: 70vh;
width: 25vw;
}
#names {
width: 100%;
max-width: 20vw;
}
p {
line-height: 0;
white-space: nowrap;
height: 100%;
}
h1,
H4 {
font-weight: 200;
margin: 0;
}
h1 {
font-size: 1.5rem;
}
h4 {
font-size: 0.75rem;
line-height: 2;
}
body {
font-family: 'Martian Mono';
overflow-x: hidden;
font-weight: 200;
font-size: 1rem;
margin: 2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 2rem;
}
body[data-theme="dark"] {
background-color: black;
color: #c9c9c9;
}
body[data-theme="light"] {
background-color: white;
color: black;
}
a {
text-decoration: none;
color: inherit;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
#mode {
position: fixed;
top: 0;
right: 0;
padding: 2rem;
cursor: pointer;
transition: color 0.3s ease;
}
@media screen and (max-width: 1000px) {
#names {
max-width: 30vw;
}
body {
margin: 1rem;
}
}
</style>
</head>
<body>
<div style="width: 100%; display: flex; flex-direction: column; justify-content: flex-start; gap: 2rem;">
<h1>Color Gamut Test</h1>
<h4>The more colors you see, the wider your display's color gamut.</h4>
</div>
<div id="mode">
<i class="material-icons" id="theme-icon">contrast</i>
</div>
<div class="row">
<div id="names" class="column">
<p>sRGB</p>
<p>AdobeRGB</p>
<p>P3</p>
<p>Rec.2020</p>
<p>ProPhoto</p>
<p>XYZ D50</p>
<p>XYZ D65</p>
</div>
<div id="red" class="column"></div>
<div id="blue" class="column"></div>
<div id="green" class="column"></div>
</div>
<h4>Made by <a href="https://x.com/juxtopposed" target="_blank">Juxtopposed</a></h4>
<script>
let colorRedSRGB = new Color("srgb", [1, 0, 0]);
let colorRedP3 = new Color("p3", [1, 0, 0]);
let colorRedA98RGB = new Color("a98rgb", [1, 0, 0]);
let colorRedREC2020 = new Color("rec2020", [1, 0, 0]);
let colorRedProPhoto = new Color("prophoto", [1, 0, 0]);
let colorRedXYZD50 = new Color("xyz-d50", [1, 0, 0]);
let colorRedXYZD65 = new Color("xyz-d65", [1, 0, 0]);
let colorBlueSRGB = new Color("srgb", [0, 0, 1]);
let colorBlueP3 = new Color("p3", [0, 0, 1]);
let colorBlueA98RGB = new Color("a98rgb", [0, 0, 1]);
let colorBlueREC2020 = new Color("rec2020", [0, 0, 1]);
let colorBlueProPhoto = new Color("prophoto", [0, 0, 1]);
let colorBlueXYZD50 = new Color("xyz-d50", [0, 0, 1]);
let colorBlueXYZD65 = new Color("xyz-d65", [0, 0, 1]);
let colorGreenSRGB = new Color("srgb", [0, 1, 0]);
let colorGreenP3 = new Color("p3", [0, 1, 0]);
let colorGreenA98RGB = new Color("a98rgb", [0, 1, 0]);
let colorGreenREC2020 = new Color("rec2020", [0, 1, 0]);
let colorGreenProPhoto = new Color("prophoto", [0, 1, 0]);
let colorGreenXYZD50 = new Color("xyz-d50", [0, 1, 0]);
let colorGreenXYZD65 = new Color("xyz-d65", [0, 1, 0]);
let A98RGBRedString = colorRedA98RGB.toString();
let P3RedString = colorRedP3.toString();
let ProPhotoRedString = colorRedProPhoto.toString();
let REC2020RedString = colorRedREC2020.toString();
let XYZD50RedString = colorRedXYZD50.toString();
let XYZD65RedString = colorRedXYZD65.toString();
let sRGBRedString = colorRedSRGB.toString();
let sRGBBlueString = colorBlueSRGB.toString();
let P3BlueString = colorBlueP3.toString();
let A98RGBBlueString = colorBlueA98RGB.toString();
let REC2020BlueString = colorBlueREC2020.toString();
let ProPhotoBlueString = colorBlueProPhoto.toString();
let XYZD50BlueString = colorBlueXYZD50.toString();
let XYZD65BlueString = colorBlueXYZD65.toString();
let sRGBGreenString = colorGreenSRGB.toString();
let P3GreenString = colorGreenP3.toString();
let A98RGBGreenString = colorGreenA98RGB.toString();
let REC2020GreenString = colorGreenREC2020.toString();
let ProPhotoGreenString = colorGreenProPhoto.toString();
let XYZD50GreenString = colorGreenXYZD50.toString();
let XYZD65GreenString = colorGreenXYZD65.toString();
// Display colors
document.getElementById("red").innerHTML = `
<div class="colors" style="background-color: ${sRGBRedString};"></div>
<div class="colors" style="background-color: ${A98RGBRedString};"></div>
<div class="colors" style="background-color: ${P3RedString};"></div>
<div class="colors" style="background-color: ${REC2020RedString};"></div>
<div class="colors" style="background-color: ${ProPhotoRedString};"></div>
<div class="colors" style="background-color: ${XYZD50RedString};"></div>
<div class="colors" style="background-color: ${XYZD65RedString};"></div>
`;
document.getElementById("blue").innerHTML = `
<div class="colors" style="background-color: ${sRGBBlueString};"></div>
<div class="colors" style="background-color: ${A98RGBBlueString};"></div>
<div class="colors" style="background-color: ${P3BlueString};"></div>
<div class="colors" style="background-color: ${REC2020BlueString};"></div>
<div class="colors" style="background-color: ${ProPhotoBlueString};"></div>
<div class="colors" style="background-color: ${XYZD50BlueString};"></div>
<div class="colors" style="background-color: ${XYZD65BlueString};"></div>
`;
document.getElementById("green").innerHTML = `
<div class="colors" style="background-color: ${sRGBGreenString};"></div>
<div class="colors" style="background-color: ${A98RGBGreenString};"></div>
<div class="colors" style="background-color: ${P3GreenString};"></div>
<div class="colors" style="background-color: ${REC2020GreenString};"></div>
<div class="colors" style="background-color: ${ProPhotoGreenString};"></div>
<div class="colors" style="background-color: ${XYZD50GreenString};"></div>
<div class="colors" style="background-color: ${XYZD65GreenString};"></div>
`;
document.addEventListener('DOMContentLoaded', () => {
const iconElement = document.getElementById('theme-icon');
let theme = 'system';
function applySystemTheme() {
const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
if (prefersDarkScheme) {
document.body.setAttribute('data-theme', 'dark');
} else {
document.body.setAttribute('data-theme', 'light');
}
iconElement.textContent = 'contrast';
}
if (theme === 'system') {
applySystemTheme();
}
iconElement.addEventListener('click', () => {
if (theme === 'system') {
theme = 'dark';
document.body.setAttribute('data-theme', 'dark');
iconElement.textContent = 'dark_mode';
} else if (theme === 'dark') {
theme = 'light';
document.body.setAttribute('data-theme', 'light');
iconElement.textContent = 'light_mode';
} else {
theme = 'system';
applySystemTheme();
}
});
});
</script>
</body>
</html>