-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
315 lines (273 loc) · 8.93 KB
/
Copy pathindex.html
File metadata and controls
315 lines (273 loc) · 8.93 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MonoInk.js - Demo</title>
<script src="./monoink.js"></script>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #ffffff;
height: 100vh;
}
.controls {
position: fixed;
top: 10px;
right: 10px;
background: rgba(0, 0, 0, 0.9);
color: #fff;
border-radius: 8px;
padding: 15px;
z-index: 10000;
min-width: 200px;
font-size: 14px;
}
.controls h3 {
margin: 0 0 15px 0;
font-size: 16px;
border-bottom: 1px solid #333;
padding-bottom: 8px;
}
.control-group {
margin-bottom: 12px;
}
.control-group label {
display: block;
margin-bottom: 6px;
font-weight: 500;
}
.control-group button {
width: 100%;
padding: 8px 12px;
border: none;
border-radius: 4px;
background: #0066cc;
color: white;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s;
}
.control-group button:hover {
background: #0052a3;
}
.control-group button.active {
background: #00cc66;
}
.control-group input[type="range"] {
width: 100%;
margin: 5px 0;
}
.control-group input[type="color"] {
width: 100%;
height: 35px;
border: none;
border-radius: 4px;
cursor: pointer;
}
.value-display {
font-family: 'Courier New', monospace;
color: #ccc;
font-size: 12px;
}
.demo-content {
max-width: 800px;
/* margin: 0 auto; */
}
.demo-section {
background: #f8f9fa;
padding: 20px;
margin: 20px 0;
border-radius: 6px;
border-left: 4px solid #007acc;
}
.retro-image {
max-width: 100%;
height: auto;
border: 2px solid #ccc;
margin: 10px 0;
}
</style>
</head>
<body>
<div class="controls">
<h3>MonoInk Controls</h3>
<div class="control-group">
<button id="toggle-pixelation">Enable Pixelation</button>
</div>
<div class="control-group">
<label for="pixelDensity">Pixel Density: <span class="value-display" id="pixelValue">0</span></label>
<input type="range" id="pixelDensity" min="1" max="100" value="1" step="1">
</div>
<div class="control-group">
<button id="toggle-dithering">Enable Dithering</button>
</div>
<div class="control-group">
<label for="ditherDensity">Dither Density: <span class="value-display" id="ditherValue">0</span></label>
<input type="range" id="ditherDensity" min="1" max="8" value="1" step="1">
</div>
<div class="control-group">
<button id="toggle-contrast">Enable High Contrast</button>
</div>
<div class="control-group">
<button id="toggle-backlight">Enable Backlight</button>
</div>
<div class="control-group">
<label for="colorPicker">Backlight Color:</label>
<input type="color" id="colorPicker" value="#ffa500">
</div>
</div>
<div class="demo-content">
<h1>MonoInk.js - Live Demo</h1>
<p>Render web content with a retro screen effect. Use the controls on the right to see the effects in action!</p>
<div class="demo-section">
<h2>Quick Preview</h2>
<p>MonoInk applies authentic retro computer display effects:</p>
<ul>
<li><strong>Pixelation</strong> - Chunky, low-resolution blocks</li>
<li><strong>Dithering</strong> - Black/white dot patterns for grayscale simulation</li>
<li><strong>High Contrast</strong> - Pure black/white conversion</li>
<li><strong>Backlight</strong> - Vintage CRT monitor colors</li>
</ul>
<p><strong>Try it:</strong> Enable pixelation + dithering for the classic retro look!</p>
</div>
<div class="demo-section">
<h3>Sample Image</h3>
<p>See how effects are applied to images in real-time:</p>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/9/91/Starlink_Mission_%2847926144123%29.jpg/640px-Starlink_Mission_%2847926144123%29.jpg" alt="Sample Image" crossorigin="anonymous" class="retro-image" />
</div>
<div class="demo-section">
<h3>Basic Usage</h3>
<pre><code><script src="monoink.js"></script>
<script>
const monoInk = new MonoInk({
pixelation: true,
pixelDensity: 4,
dithering: true
});
monoInk.render();
</script></code></pre>
<p>See the <a href="README.md" target="_blank">README</a> for complete documentation and examples.</p>
</div>
</div>
<script>
// Initialize MonoInk with optimized settings
const monoInk = new MonoInk({
pixelDensity: 4,
ditherDensity: 1,
pixelation: false,
dithering: false,
backlight: false,
backlightColor: { r: 255, g: 165, b: 0 },
highContrast: false,
});
monoInk.render();
// Control elements
const pixelationBtn = document.getElementById('toggle-pixelation');
const pixelSlider = document.getElementById('pixelDensity');
const pixelValue = document.getElementById('pixelValue');
const ditherBtn = document.getElementById('toggle-dithering');
const ditherSlider = document.getElementById('ditherDensity');
const ditherValue = document.getElementById('ditherValue');
const contrastBtn = document.getElementById('toggle-contrast');
const backlightBtn = document.getElementById('toggle-backlight');
const colorPicker = document.getElementById('colorPicker');
// Pixelation toggle
pixelationBtn.addEventListener('click', () => {
const newState = !monoInk.pixelation;
monoInk.updateSettings({ pixelation: newState });
pixelationBtn.textContent = newState ? 'Disable Pixelation' : 'Enable Pixelation';
pixelationBtn.className = newState ? 'active' : '';
if (newState) {
// Jump slider to good default when enabling
const defaultValue = 4;
pixelSlider.value = defaultValue;
pixelValue.textContent = defaultValue;
monoInk.updateSettings({ pixelDensity: defaultValue });
} else {
// Set display value to 0 and slider to minimum when disabled
pixelValue.textContent = 0;
pixelSlider.value = pixelSlider.min;
}
});
// Pixel density control
pixelSlider.addEventListener('input', (e) => {
const value = parseInt(e.target.value);
pixelValue.textContent = value;
monoInk.updateSettings({ pixelDensity: value });
// Auto-enable pixelation when slider is used
if (!monoInk.pixelation) {
monoInk.updateSettings({ pixelation: true });
pixelationBtn.textContent = 'Disable Pixelation';
pixelationBtn.className = 'active';
}
});
// Dithering toggle
ditherBtn.addEventListener('click', () => {
const newState = !monoInk.dithering;
monoInk.updateSettings({ dithering: newState });
ditherBtn.textContent = newState ? 'Disable Dithering' : 'Enable Dithering';
ditherBtn.className = newState ? 'active' : '';
if (newState) {
// Jump slider to good default when enabling
const defaultValue = 1;
ditherSlider.value = defaultValue;
ditherValue.textContent = defaultValue;
monoInk.updateSettings({ ditherDensity: defaultValue });
} else {
// Set display value to 0 and slider to minimum when disabled
ditherValue.textContent = 0;
ditherSlider.value = ditherSlider.min;
}
});
// Dither density control
ditherSlider.addEventListener('input', (e) => {
const value = parseInt(e.target.value);
ditherValue.textContent = value;
monoInk.updateSettings({ ditherDensity: value });
// Auto-enable dithering when slider is used
if (!monoInk.dithering) {
monoInk.updateSettings({ dithering: true });
ditherBtn.textContent = 'Disable Dithering';
ditherBtn.className = 'active';
}
});
// High contrast toggle
contrastBtn.addEventListener('click', () => {
const newState = !monoInk.highContrast;
monoInk.updateSettings({ highContrast: newState });
contrastBtn.textContent = newState ? 'Disable High Contrast' : 'Enable High Contrast';
contrastBtn.className = newState ? 'active' : '';
});
// Backlight toggle
backlightBtn.addEventListener('click', () => {
const newState = !monoInk.backlight;
monoInk.updateSettings({ backlight: newState });
backlightBtn.textContent = newState ? 'Disable Backlight' : 'Enable Backlight';
backlightBtn.className = newState ? 'active' : '';
});
// Color picker
colorPicker.addEventListener('input', (e) => {
const hex = e.target.value;
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
monoInk.updateSettings({
backlightColor: { r, g, b },
backlight: true
});
backlightBtn.textContent = 'Disable Backlight';
backlightBtn.className = 'active';
});
// Initialize UI state
// No active states by default
// Cleanup on page unload
window.addEventListener('beforeunload', () => {
monoInk.destroy();
});
</script>
</body>
</html>