-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
496 lines (482 loc) · 22.7 KB
/
index.html
File metadata and controls
496 lines (482 loc) · 22.7 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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Lilo - Cross Stitch Converter</title>
<meta name="description" content="Browser-only cross stitch pattern generator. Convert images to stitch patterns, edit, and export PDF." />
<meta name="theme-color" content="#111827" />
<link rel="icon" href="favicon.svg" type="image/svg+xml" />
<link rel="manifest" href="manifest.json" />
<link rel="apple-touch-icon" href="apple-touch-icon.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="Lilo" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@300;400;500;600;700&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/solid.min.css"
referrerpolicy="no-referrer"
/>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div class="page">
<header class="hero">
<div>
<p class="eyebrow">Cross stitch planner</p>
<div class="brand">
<svg class="brand-mark" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
<g stroke="currentColor" stroke-width="3" stroke-linecap="round" transform="translate(10, 10)">
<line x1="12" y1="12" x2="23" y2="23" />
<line x1="23" y1="12" x2="12" y2="23" />
<line x1="27" y1="12" x2="38" y2="23" />
<line x1="38" y1="12" x2="27" y2="23" />
<line x1="42" y1="12" x2="53" y2="23" />
<line x1="53" y1="12" x2="42" y2="23" />
<line x1="57" y1="12" x2="68" y2="23" />
<line x1="68" y1="12" x2="57" y2="23" />
<line x1="12" y1="27" x2="23" y2="38" />
<line x1="23" y1="27" x2="12" y2="38" />
<line x1="57" y1="27" x2="68" y2="38" />
<line x1="68" y1="27" x2="57" y2="38" />
<line x1="12" y1="42" x2="23" y2="53" />
<line x1="23" y1="42" x2="12" y2="53" />
<line x1="57" y1="42" x2="68" y2="53" />
<line x1="68" y1="42" x2="57" y2="53" />
<line x1="12" y1="57" x2="23" y2="68" />
<line x1="23" y1="57" x2="12" y2="68" />
<line x1="27" y1="57" x2="38" y2="68" />
<line x1="38" y1="57" x2="27" y2="68" />
<line x1="42" y1="57" x2="53" y2="68" />
<line x1="53" y1="57" x2="42" y2="68" />
<line x1="57" y1="57" x2="68" y2="68" />
<line x1="68" y1="57" x2="57" y2="68" />
</g>
</svg>
<h1>Lilo</h1>
</div>
<p class="lede">
Turn any photo into a stitch-ready pattern. Upload an image, pick a palette, and
limit the color count for a clean thread plan.
</p>
</div>
<div class="hero-card export-card">
<p class="hero-title">Export</p>
<div class="export-controls">
<div class="export-mode">
<label class="field">
<span>PDF render mode</span>
<select id="patternMode">
<option value="color-symbols">Color and Icons</option>
<option value="color">Only Color</option>
<option value="symbols">Only Icons</option>
</select>
</label>
<label class="switch export-split">
<input id="pdfSplit" type="checkbox" role="switch" class="switch-input" checked />
<span>Splitted</span>
</label>
</div>
<div class="export-actions">
<button id="printPdf" class="primary has-tooltip" data-tip="Download the stitched pattern as a multi-page PDF.">
<i data-lucide="file-down"></i>
Download PDF
<span class="spinner" aria-hidden="true"></span>
</button>
<button id="saveProject" class="ghost icon-button">
<i data-lucide="save"></i>
Save project
</button>
<button id="loadProject" class="ghost icon-button">
<i data-lucide="folder-open"></i>
Load project
</button>
<input id="projectFile" type="file" accept=".lilo" hidden />
</div>
</div>
</div>
</header>
<main class="workspace">
<section class="panel controls" x-data="{ open: 'basic' }">
<div class="controls-header">
<div>
<h2>Settings</h2>
</div>
</div>
<div class="control-group">
<h3 class="control-group-title">Image</h3>
<label id="imageUploadLabel" class="file-label has-tooltip" for="imageUpload" data-tip="Upload a local image (JPG, PNG, SVG, and more) to convert into a pattern.">
<input id="imageUpload" type="file" accept="image/*" />
<i data-lucide="image"></i>
<span>Choose image</span>
</label>
<p></p>
</div>
<div class="accordion">
<div class="accordion-item" :class="{ open: open === 'basic' }">
<button class="accordion-trigger" type="button" @click="open = open === 'basic' ? null : 'basic'">
<span class="accordion-title">
<i data-lucide="sliders"></i>
Basic settings
</span>
<span class="accordion-meta">Colors & grid</span>
</button>
<div class="accordion-content" x-show="open === 'basic'" x-transition x-cloak>
<div class="control-group">
<label class="field">
<span class="has-tooltip" data-tip="Maximum number of thread colors used in the pattern.">Number of colors</span>
<input id="colorLimit" type="range" min="3" max="32" value="10" />
<div class="range-meta">
<span id="colorLimitValue">10</span>
<span class="muted">colors</span>
</div>
</label>
</div>
<div class="control-group">
<h4 class="control-group-title">Grid size</h4>
<div class="three-col fabric-grid">
<label class="field">
<span class="has-tooltip" data-tip="Final stitch count across the width.">Grid width (stitches)</span>
<input id="gridWidth" type="number" min="10" max="1000" value="80" />
</label>
<label class="field">
<span class="has-tooltip" data-tip="Final stitch count across the height.">Grid height (stitches)</span>
<input id="gridHeight" type="number" min="10" max="1000" value="80" />
</label>
</div>
<div class="inline">
<label class="check has-tooltip" data-tip="Keep the original image aspect ratio when changing size.">
<input id="lockAspect" type="checkbox" checked />
<span>Lock aspect ratio</span>
</label>
<button class="ghost has-tooltip" id="useOriginal" data-tip="Reset grid size to the image’s original pixel dimensions.">
Use original size
</button>
</div>
</div>
</div>
</div>
<div class="accordion-item" :class="{ open: open === 'palette' }">
<button class="accordion-trigger" type="button" @click="open = open === 'palette' ? null : 'palette'">
<span class="accordion-title">
<i data-lucide="palette"></i>
Colors and symbols
</span>
<span class="accordion-meta">Palette & symbols</span>
</button>
<div class="accordion-content" x-show="open === 'palette'" x-transition x-cloak>
<div class="control-group">
<label class="field has-tooltip" data-tip="Select the thread palette used to map colors.">
<span>Palette</span>
<select id="paletteSelect"></select>
</label>
</div>
<div class="control-group">
<label class="field has-tooltip" data-tip="Choose which symbol collection is used for icon assignments.">
<span>Symbol set</span>
<select id="symbolSet"></select>
<p class="hint">Switching sets resets symbol assignments.</p>
</label>
<button id="randomizeSymbols" class="ghost icon-button symbol-action" type="button">
<i data-lucide="shuffle"></i>
Randomize symbols
</button>
</div>
</div>
</div>
<div class="accordion-item" :class="{ open: open === 'rendering' }">
<button class="accordion-trigger" type="button" @click="open = open === 'rendering' ? null : 'rendering'">
<span class="accordion-title">
<i data-lucide="sparkles"></i>
Image rendering
</span>
<span class="accordion-meta">Processing</span>
</button>
<div class="accordion-content" x-show="open === 'rendering'" x-transition x-cloak>
<div class="control-group">
<label class="field">
<span class="has-tooltip" data-tip="Adds pixel-level blending between colors for smoother gradients.">Dither strength</span>
<input id="ditherStrength" type="range" min="0" max="100" value="0" />
<div class="range-meta">
<span id="ditherStrengthValue">0</span>
<span class="muted">pixel blending</span>
</div>
</label>
<label class="field">
<span class="has-tooltip" data-tip="Adjusts overall image brightness.">Brightness</span>
<input id="brightness" type="range" min="-50" max="50" value="0" />
<div class="range-meta">
<span id="brightnessValue">0</span>
<span class="muted">% adjust</span>
</div>
</label>
<label class="field">
<span class="has-tooltip" data-tip="Adjusts contrast between light and dark areas.">Contrast</span>
<input id="contrast" type="range" min="-50" max="50" value="0" />
<div class="range-meta">
<span id="contrastValue">0</span>
<span class="muted">% adjust</span>
</div>
</label>
<label class="field">
<span class="has-tooltip" data-tip="Softens the image before color mapping.">Blur strength</span>
<input id="blurStrength" type="range" min="0" max="4" value="0" step="0.5" />
<div class="range-meta">
<span id="blurValue">0</span>
<span class="muted">px</span>
</div>
</label>
</div>
<div class="control-group">
<label class="check has-tooltip" data-tip="Smooths the image before color mapping.">
<input id="smoothing" type="checkbox" />
<span>Enable smoothing</span>
</label>
</div>
<div class="control-group">
<label class="field">
<span class="has-tooltip" data-tip="Reserve slots for high-saturation colors.">Accent slots</span>
<input id="accentSlots" type="number" min="0" max="4" value="2" />
<p class="hint">Reserve colors for strong accents.</p>
</label>
</div>
</div>
</div>
<div class="accordion-item" :class="{ open: open === 'fabric' }">
<button class="accordion-trigger" type="button" @click="open = open === 'fabric' ? null : 'fabric'">
<span class="accordion-title">
<i data-lucide="ruler"></i>
Fabric sizing
</span>
<span class="accordion-meta">Finished size</span>
</button>
<div class="accordion-content" x-show="open === 'fabric'" x-transition x-cloak>
<div class="control-group">
<div class="three-col">
<label class="field">
<span class="has-tooltip" data-tip="Fabric type presets for common stitch counts.">Fabric type</span>
<select id="fabricType"></select>
</label>
<label class="field">
<span class="has-tooltip" data-tip="Stitches per inch or cm for your fabric.">Fabric count</span>
<select id="fabricCount"></select>
</label>
<label class="field">
<span class="has-tooltip" data-tip="Use stitches per inch or per cm.">Count unit</span>
<select id="fabricUnit">
<option value="inch">Stitches per inch</option>
<option value="cm">Stitches per cm</option>
</select>
</label>
</div>
<div class="size-readout">
<div>
<span class="muted">Estimated size</span>
<strong id="sizeCm">0 cm x 0 cm</strong>
</div>
<div>
<span class="muted">In inches</span>
<strong id="sizeIn">0 in x 0 in</strong>
</div>
</div>
</div>
</div>
</div>
</div>
<input id="stitchSize" type="hidden" value="10" />
</section>
<section class="panel preview">
<div class="preview-header">
<h2>Preview</h2>
<label class="switch sticky-toggle" title="Keep preview visible while scrolling">
<input id="stickyPreview" type="checkbox" role="switch" class="switch-input switch-input-sm" />
<span>Sticky</span>
</label>
<p class="hint" id="status">Upload an image to begin.</p>
</div>
<div class="canvas-stack">
<div>
<h3>Source</h3>
<canvas id="sourceCanvas" width="320" height="240"></canvas>
</div>
<div>
<h3>Cross stitch</h3>
<canvas id="outputCanvas" width="320" height="240"></canvas>
</div>
</div>
<div class="preview-actions">
<button id="openManage" class="primary">Edit</button>
</div>
</section>
<section class="panel legend">
<div class="legend-header">
<h2>Legend</h2>
<span class="legend-help">
<i data-lucide="info"></i>
<div class="legend-popover">
<div class="legend-popover-title">Legend tips</div>
<p>Click a symbol to change the icon for that color.</p>
</div>
</span>
</div>
<div id="legendList" class="legend-list">
<p class="hint">Legend will populate after conversion.</p>
</div>
<div class="legend-footer">
<button id="mergeDuplicateColors" class="ghost icon-button" type="button">
<i data-lucide="git-merge"></i>
Merge duplicates
</button>
</div>
</section>
<div id="symbolPicker" class="symbol-picker" aria-hidden="true">
<div class="symbol-picker-header">
<strong>Choose symbol</strong>
<button id="symbolPickerClose" class="ghost icon-button" type="button" aria-label="Close">
<i data-lucide="x"></i>
</button>
</div>
<div id="symbolPickerList" class="symbol-picker-grid"></div>
</div>
</main>
<footer class="site-footer">
<a class="footer-link" href="https://github.com/slok/lilo" target="_blank" rel="noreferrer">
<i data-lucide="github"></i>
Source code
</a>
<span class="footer-divider" aria-hidden="true">•</span>
<a class="footer-link" href="https://slok.dev" target="_blank" rel="noreferrer">
<i data-lucide="user"></i>
Xabier Larrakoetxea
</a>
</footer>
<div class="modal" id="paletteSearchModal" aria-hidden="true">
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="paletteSearchTitle">
<div class="modal-header">
<div>
<p class="eyebrow">Palette search</p>
<h2 id="paletteSearchTitle">Replace color</h2>
</div>
<button class="ghost" id="paletteSearchClose" type="button">Close</button>
</div>
<div class="modal-body">
<label class="field">
<span>Search by name, #hex, or @code</span>
<input id="paletteSearchInput" type="text" placeholder="rose, #ffd4c0, @310" />
</label>
<div class="modal-meta">
<span class="hint" id="paletteSearchCount">0 matches</span>
</div>
<div class="search-results" id="paletteSearchResults"></div>
</div>
</div>
</div>
<div class="modal" id="manageModal" aria-hidden="true">
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="manageTitle">
<div class="modal-header">
<div>
<div class="modal-title">
<h2 id="manageTitle">Cross stitch editor</h2>
<span class="manage-help">
<i data-lucide="command"></i>
<div class="manage-popover">
<div class="manage-popover-title">Keybindings</div>
<ul>
<li><kbd class="kbd">Right click</kbd> Select color</li>
<li><kbd class="kbd">Ctrl</kbd> + <kbd class="kbd">Z</kbd> Undo</li>
<li><kbd class="kbd">Ctrl</kbd> + <kbd class="kbd">Shift</kbd> + <kbd class="kbd">Z</kbd> Redo</li>
</ul>
</div>
</span>
</div>
</div>
<div class="modal-actions">
<button class="ghost icon-button" id="manageMaximize" type="button" title="Maximize">
<i data-lucide="maximize-2"></i>
</button>
<button class="ghost icon-button" id="manageClose" type="button" aria-label="Close">
<i data-lucide="x"></i>
</button>
</div>
</div>
<div class="modal-body">
<div class="manage-toolbar">
<div class="manage-modes">
<div role="group" class="button-group">
<button id="managePick" class="ghost icon-button">
<i data-lucide="pipette"></i>
Pick
</button>
<button id="managePaint" class="ghost icon-button">
<i data-lucide="paintbrush"></i>
Paint
</button>
<button id="manageBucket" class="ghost icon-button">
<i data-lucide="paint-bucket"></i>
Fill
</button>
</div>
<button id="manageSelect" class="ghost icon-button">
<i data-lucide="palette"></i>
Add color
</button>
<div role="group" class="button-group">
<button id="manageUndo" class="ghost icon-button" title="Undo">
<i data-lucide="undo-2"></i>
Undo
</button>
<button id="manageRedo" class="ghost icon-button" title="Redo">
<i data-lucide="redo-2"></i>
Redo
</button>
</div>
</div>
<div class="manage-selected">
<div id="manageSwatch" class="manage-swatch"></div>
<div class="manage-meta">
<strong id="manageColorName">No color selected</strong>
<div id="manageColorCode" class="manage-code"></div>
</div>
<span id="managePendingBadge" class="manage-badge">New</span>
</div>
</div>
<div class="preview-controls">
<label class="field">
<span>Zoom</span>
<input id="previewZoom" type="range" min="0.5" max="4" step="0.1" value="1" />
<div class="range-meta">
<span id="previewZoomValue">1x</span>
<span class="muted">preview scale</span>
</div>
</label>
</div>
<div class="preview-scroll">
<canvas id="manageCanvas" class="pixel-canvas" width="320" height="240"></canvas>
</div>
</div>
</div>
</div>
</div>
<script src="dmc-palette.js"></script>
<script src="dmc-anchor-map.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/lucide.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jszip.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/pdf-lib.min.js"></script>
<script src="https://unpkg.com/@pdf-lib/[email protected]/dist/fontkit.umd.min.js"></script>
<script src="pdf-export.js"></script>
<script src="app.js"></script>
<div id="toast" class="toast" role="status" aria-live="polite"></div>
<script>
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("/sw.js");
}
</script>
</body>
</html>