-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
269 lines (238 loc) · 6.41 KB
/
index.html
File metadata and controls
269 lines (238 loc) · 6.41 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ALEX DECLINO</title>
<style>
* {
font-family: monospace;
padding: 0;
line-height: 1.3rem;
}
body {
margin: 8px;
background-color: #ffffff;
color: #111111;
}
h2 {
margin-left: 0.83em;
}
.version {
font-size: 0.75rem;
font-weight: normal;
color: #666;
}
.quote-line {
margin-left: calc(2 * 0.83em);
font-size: 0.85rem;
color: #666;
}
a {
color: red;
}
a:visited {
color: #990000;
}
#dice {
cursor: pointer;
color: red;
}
#frame {
position: relative;
width: 400px;
height: 400px;
background: #111;
overflow: hidden;
margin-top: 0.25rem;
margin-left: calc(2 * 0.83em);
max-width: calc(100vw - 3em);
aspect-ratio: 1;
}
@media (max-width: 480px) {
h2 {
margin-left: 0;
}
.quote-line {
margin-left: 0;
}
#frame {
width: calc(100vw - 16px);
height: auto;
margin-left: 0;
}
#dither {
width: 100%;
height: 100%;
}
.contacts {
margin-left: 0;
max-width: none;
width: auto;
}
}
#frame img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: fill;
opacity: 0;
transition: opacity 0.5s ease;
filter: saturate(5) contrast(2.5) brightness(1.2) hue-rotate(-15deg);
}
#frame img.active {
opacity: 1;
}
#dither {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
}
.contacts {
margin-left: calc(2 * 0.83em);
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid #ccc;
font-size: 0.85rem;
max-width: 400px;
}
@media (prefers-color-scheme: dark) {
body {
background-color: #111111;
color: #eeeeee;
}
#frame {
background: #222;
}
.quote-line {
color: #888;
}
.version {
color: #888;
}
.contacts {
border-color: #333;
}
}
@media (prefers-color-scheme: light) {
body {
background-color: #ffffff;
color: #111111;
}
}
</style>
</head>
<body>
<h2>ALEX DECLINO <span class="version">v.0.0.5</span></h2>
<div class="quote-line"><span id="quote"></span> <span id="dice" onclick="loadQuote()">[꩜]</span></div>
<div id="frame">
<img id="img1" src="" alt="" crossorigin="anonymous">
<img id="img2" src="" alt="" crossorigin="anonymous">
<canvas id="dither" width="400" height="400"></canvas>
</div>
<div class="contacts">
<a href="https://instagram.com/alexdeclino" target="_blank">ig</a> |
<a href="https://x.com/alexdeclino" target="_blank">x</a> |
<a href="https://are.na/alex-declino" target="_blank">arena</a> |
<a href="https://t.me/alexdeclino" target="_blank">tg</a>
</div>
<script src="config.js"></script>
<script>
const API_URL = `https://api.are.na/v2/channels/${CHANNEL_SLUG}?per=100`;
const QUOTES_API = 'https://api.are.na/v2/channels/npc-dialogues?per=100';
let images = [];
const img1 = document.getElementById('img1');
const img2 = document.getElementById('img2');
const ditherCanvas = document.getElementById('dither');
const ditherCtx = ditherCanvas.getContext('2d');
const sampleCanvas = document.createElement('canvas');
const sampleCtx = sampleCanvas.getContext('2d');
sampleCanvas.width = 400;
sampleCanvas.height = 400;
let current = 1;
async function init() {
try {
const response = await fetch(API_URL);
if (!response.ok) throw new Error('Failed to fetch');
const data = await response.json();
images = data.contents.filter(block => block.class === 'Image');
if (images.length === 0) return;
// preload
images.forEach(block => {
const preload = new Image();
preload.crossOrigin = 'anonymous';
preload.src = block.image.display.url;
});
showRandom();
setInterval(showRandom, 200);
} catch (error) {
console.error(error);
}
}
function drawDither(imgEl) {
ditherCtx.clearRect(0, 0, 400, 400);
ditherCtx.fillStyle = 'rgba(0, 0, 0, 0.4)';
try {
sampleCtx.drawImage(imgEl, 0, 0, 400, 400);
const imageData = sampleCtx.getImageData(0, 0, 400, 400);
const pixels = imageData.data;
const lineSpacing = 6;
for (let y = 0; y < 400; y += lineSpacing) {
for (let x = 0; x < 400; x += 3) {
const i = (y * 400 + x) * 4;
const brightness = (pixels[i] + pixels[i+1] + pixels[i+2]) / 3;
const lineHeight = Math.floor((1 - brightness / 255) * (lineSpacing - 1)) + 1;
ditherCtx.fillRect(x, y, 3, lineHeight);
}
}
} catch (e) {
// CORS fallback - just draw regular scan lines
for (let y = 0; y < 400; y += 4) {
ditherCtx.fillRect(0, y, 400, 2);
}
}
}
function showRandom() {
const block = images[Math.floor(Math.random() * images.length)];
if (current === 1) {
img2.src = block.image.display.url;
img2.onload = () => {
img1.classList.remove('active');
img2.classList.add('active');
drawDither(img2);
current = 2;
};
} else {
img1.src = block.image.display.url;
img1.onload = () => {
img2.classList.remove('active');
img1.classList.add('active');
drawDither(img1);
current = 1;
};
}
}
async function loadQuote() {
try {
const response = await fetch(QUOTES_API);
if (!response.ok) return;
const data = await response.json();
const texts = data.contents.filter(block => block.class === 'Text');
if (texts.length === 0) return;
const random = texts[Math.floor(Math.random() * texts.length)];
document.getElementById('quote').textContent = `"${random.content}"`;
} catch (error) {
console.error(error);
}
}
init();
loadQuote();
</script>
</body>
</html>