-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabout.html
More file actions
650 lines (554 loc) · 31.4 KB
/
about.html
File metadata and controls
650 lines (554 loc) · 31.4 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
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About | Dev Tartan</title>
<meta name="description" content="How Dev Tartan works: SHA-256 hashing, sett derivation, SVG rendering, and Web Audio bagpipes. The nerdy details behind turning a GitHub username into a deterministic tartan.">
<meta name="robots" content="index, follow">
<meta name="theme-color" content="#1c2541">
<meta property="og:image" content="https://leereilly.net/dev-tartan/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="Dev Tartan — a unique tartan pattern generated from a GitHub username">
<link rel="canonical" href="https://leereilly.net/dev-tartan/about.html">
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' fill='%231c2541'/%3E%3Crect x='0' y='6' width='32' height='4' fill='%238b1a1a' opacity='0.8'/%3E%3Crect x='0' y='22' width='32' height='4' fill='%238b1a1a' opacity='0.8'/%3E%3Crect x='6' y='0' width='4' height='32' fill='%231a472a' opacity='0.8'/%3E%3Crect x='22' y='0' width='4' height='32' fill='%231a472a' opacity='0.8'/%3E%3Crect x='14' y='0' width='2' height='32' fill='%23c5a041' opacity='0.6'/%3E%3Crect x='0' y='14' width='32' height='2' fill='%23c5a041' opacity='0.6'/%3E%3C/svg%3E">
<link rel="preload" href="https://cdn.jsdelivr.net/fontsource/fonts/mona-sans:vf@latest/latin-wght-normal.woff2" as="font" type="font/woff2" crossorigin>
<style>
@font-face {
font-family: 'Mona Sans';
font-style: normal;
font-display: swap;
font-weight: 200 900;
src: url('https://cdn.jsdelivr.net/fontsource/fonts/mona-sans:vf@latest/latin-wght-normal.woff2') format('woff2-variations');
}
</style>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
min-height: 100vh;
background: #f4edd3;
background-image:
repeating-linear-gradient(0deg, transparent, transparent 50px, rgba(139,119,75,0.03) 50px, rgba(139,119,75,0.03) 51px),
repeating-linear-gradient(90deg, transparent, transparent 50px, rgba(139,119,75,0.03) 50px, rgba(139,119,75,0.03) 51px);
font-family: 'Mona Sans', sans-serif;
color: #2c1810;
display: flex;
flex-direction: column;
align-items: center;
padding: 2rem 1rem;
}
header {
text-align: center;
margin-bottom: 2rem;
}
header h1 {
font-family: 'Mona Sans', sans-serif;
font-size: 2.8rem;
font-weight: 700;
color: #1a0f08;
letter-spacing: 0.04em;
margin-bottom: 0.25rem;
}
header h1 a {
color: inherit;
text-decoration: none;
}
header h1 a:hover {
text-decoration: underline;
text-decoration-color: #8b2500;
text-underline-offset: 4px;
}
header h1 .accent { color: #8b2500; }
.divider {
width: 200px;
height: 2px;
background: linear-gradient(90deg, transparent, #8b774b, transparent);
margin: 0.75rem auto;
}
.header-nav {
display: flex;
justify-content: center;
gap: 1.5rem;
margin-top: 0.5rem;
}
.header-nav a {
font-family: 'Mona Sans', sans-serif;
font-size: 1rem;
color: #6b5240;
text-decoration: none;
padding: 0.2rem 0;
border-bottom: 1px solid transparent;
transition: all 0.2s;
}
.header-nav a:hover {
color: #8b2500;
border-bottom-color: #8b2500;
}
.content {
max-width: 720px;
width: 100%;
line-height: 1.75;
}
.content h2 {
font-family: 'Mona Sans', sans-serif;
font-size: 1.6rem;
color: #3d2b1f;
margin: 2rem 0 0.75rem;
}
.content h2:first-child {
margin-top: 0;
}
.content h3 {
font-family: 'Mona Sans', sans-serif;
font-size: 1.2rem;
color: #5a4232;
margin: 1.5rem 0 0.5rem;
}
.content p {
margin-bottom: 1rem;
font-size: 1.1rem;
}
.content ul, .content ol {
margin: 0.5rem 0 1rem 1.5rem;
font-size: 1.1rem;
}
.content li {
margin-bottom: 0.4rem;
}
.content code {
font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
font-size: 0.9em;
background: rgba(139,119,75,0.1);
padding: 0.15em 0.4em;
border-radius: 3px;
color: #5a4232;
}
.content pre {
background: #2c1810;
color: #f0e8d0;
padding: 1rem 1.25rem;
border-radius: 6px;
overflow-x: auto;
margin: 0.75rem 0 1.25rem;
font-size: 0.9rem;
line-height: 1.6;
}
.content pre code {
background: none;
padding: 0;
color: inherit;
font-size: inherit;
}
.content a {
color: #8b2500;
text-decoration: underline;
text-underline-offset: 2px;
text-decoration-color: rgba(139,37,0,0.3);
transition: text-decoration-color 0.2s;
}
.content a:hover {
text-decoration-color: #8b2500;
}
.content .table-wrap {
overflow-x: auto;
margin: 0.75rem 0 1.25rem;
}
.content table {
border-collapse: collapse;
width: 100%;
font-size: 1rem;
}
.content th, .content td {
padding: 0.5rem 0.75rem;
border: 1px solid #c4b48a;
text-align: left;
}
.content th {
background: rgba(139,119,75,0.12);
font-family: 'Mona Sans', sans-serif;
font-weight: 700;
font-size: 0.95rem;
color: #3d2b1f;
}
.content td code {
font-size: 0.85em;
}
footer {
margin-top: auto;
padding-top: 2rem;
text-align: center;
color: #8b774b;
font-size: 0.9rem;
font-style: italic;
}
footer a {
color: #8b774b;
}
.illustration {
margin: 1.25rem 0;
text-align: center;
}
.illustration svg,
.illustration img {
border-radius: 4px;
border: 1px solid #c4b48a;
max-width: 100%;
height: auto;
}
.illustration-caption {
font-size: 0.9rem;
color: #6b5240;
font-style: italic;
margin-top: 0.5rem;
}
.illustration-row {
display: flex;
justify-content: center;
align-items: center;
gap: 1rem;
flex-wrap: wrap;
}
.illustration-row .illustration-label {
font-size: 0.85rem;
color: #5a4232;
text-align: center;
margin-top: 0.3rem;
}
.illustration-row .illustration-op {
font-size: 1.5rem;
color: #8b774b;
font-family: 'Mona Sans', sans-serif;
}
/* ── Skip link ───────────────────────────────────────── */
.skip-link {
position: absolute;
left: -9999px;
top: 0;
background: #8b2500;
color: #f4edd3;
padding: 0.5rem 1rem;
z-index: 1000;
font-family: 'Mona Sans', sans-serif;
border-radius: 0 0 4px 0;
}
.skip-link:focus {
left: 0;
}
/* ── Focus-visible ────────────────────────────────────── */
:focus-visible {
outline: 2px solid #8b2500;
outline-offset: 2px;
}
@media (max-width: 600px) {
header h1 { font-size: 2rem; }
.content h2 { font-size: 1.3rem; }
.content { padding: 0 0.25rem; }
.illustration-row { gap: 0.5rem; }
.illustration-row svg { width: 100px; height: 100px; }
}
/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
/* ── Theme toggle button ─────────────────────────────── */
.theme-toggle {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 1000;
background: rgba(44,24,16,0.08);
border: 2px solid rgba(139,119,75,0.3);
border-radius: 50%;
width: 44px;
height: 44px;
cursor: pointer;
font-size: 1.4rem;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.3s, border-color 0.3s, transform 0.2s;
backdrop-filter: blur(8px);
-webkit-backdrop-filter: blur(8px);
}
.theme-toggle:hover {
background: rgba(44,24,16,0.15);
border-color: rgba(139,119,75,0.5);
transform: scale(1.1);
}
.theme-toggle:active { transform: scale(0.95); }
.theme-toggle .icon-sun { display: inline; }
.theme-toggle .icon-moon { display: none; }
.dark-mode .theme-toggle {
background: rgba(240,232,208,0.1);
border-color: rgba(107,82,64,0.5);
}
.dark-mode .theme-toggle:hover {
background: rgba(240,232,208,0.2);
border-color: rgba(224,112,64,0.6);
}
.dark-mode .theme-toggle .icon-sun { display: none; }
.dark-mode .theme-toggle .icon-moon { display: inline; }
/* ── Dark mode ────────────────────────────────────────── */
body.dark-mode {
background: #1a1a2e;
background-image:
repeating-linear-gradient(0deg, transparent, transparent 50px, rgba(139,119,75,0.05) 50px, rgba(139,119,75,0.05) 51px),
repeating-linear-gradient(90deg, transparent, transparent 50px, rgba(139,119,75,0.05) 50px, rgba(139,119,75,0.05) 51px);
color: #e0d8c0;
}
body.dark-mode header h1, body.dark-mode header h1 a { color: #f0e8d0; }
body.dark-mode header h1 a:hover { text-decoration-color: #e07040; }
body.dark-mode .header-nav a { color: #b5a78a; }
body.dark-mode .header-nav a:hover { color: #e07040; border-bottom-color: #e07040; }
body.dark-mode .divider { background: linear-gradient(90deg, transparent, #6b5240, transparent); }
body.dark-mode .content h2 { color: #f0e8d0; }
body.dark-mode .content h3 { color: #d0c8b0; }
body.dark-mode .content p, body.dark-mode .content li { color: #e0d8c0; }
body.dark-mode .content code { background: rgba(139,119,75,0.2); color: #d0c8b0; }
body.dark-mode .content pre { background: #0e0e1a; color: #f0e8d0; }
body.dark-mode .content a { color: #e07040; text-decoration-color: rgba(224,112,64,0.3); }
body.dark-mode .content a:hover { text-decoration-color: #e07040; }
body.dark-mode .content th { background: rgba(139,119,75,0.15); color: #f0e8d0; }
body.dark-mode .content th, body.dark-mode .content td { border-color: #6b5240; }
body.dark-mode .illustration svg, body.dark-mode .illustration img { border-color: #6b5240; }
body.dark-mode .illustration-caption { color: #b5a78a; }
body.dark-mode .illustration-row .illustration-label { color: #b5a78a; }
body.dark-mode .illustration-row .illustration-op { color: #b5a78a; }
body.dark-mode footer { color: #6b5240; }
body.dark-mode footer a { color: #6b5240; }
body.dark-mode :focus-visible { outline-color: #e07040; }
body.dark-mode .skip-link { background: #e07040; color: #1a1a2e; }
</style>
</head>
<body>
<button class="theme-toggle" id="theme-toggle" aria-label="Toggle dark mode" title="Toggle light/dark mode">
<span class="icon-sun">☀️</span>
<span class="icon-moon">🌙</span>
</button>
<a href="#about-content" class="skip-link">Skip to content</a>
<header>
<h1><a href="index.html">Dev <span class="accent">Tartan</span></a></h1>
<div class="divider"></div>
<nav class="header-nav">
<a href="index.html">Home</a>
<a href="about.html">About</a>
<a href="https://github.com/leereilly/dev-tartan">Source</a>
</nav>
</header>
<div class="content" id="about-content">
<h2>About Dev Tartan</h2>
<p>Dev Tartan generates a unique, deterministic tartan pattern from any GitHub username. Same username, same tartan, every time. It is a single HTML file with zero dependencies: no npm, no build step, no framework, no existential dread. Your build pipeline is your browser.</p>
<p>It was built entirely using <a href="https://github.com/features/copilot/cli">GitHub Copilot CLI</a> for the <a href="https://dev.to/leereilly/dev-tartan-deterministic-plaid-from-a-github-username-101m">GitHub Copilot CLI Coding Challenge</a>.</p>
<h2>What Are Tartans and Kilts?</h2>
<p>A tartan is a pattern of crisscrossed horizontal and vertical stripes in multiple colors, originating in woven cloth. Each tartan's unique arrangement of colors and stripe widths is called a <strong>sett</strong>, and specific tartans have historically been associated with Scottish clans, families, and regions. A kilt is the traditional Scottish garment made from tartan cloth — a knee-length, pleated wrap worn around the waist. Once everyday Highland dress, kilts are now most often seen at weddings, ceilidhs, and other formal occasions.</p>
<div class="illustration">
<img src="lee-michelle.png" alt="Lee wearing a kilt at his wedding with his wife Michelle" width="600">
<div class="illustration-caption">Me in a kilt getting married to my smokin' hot wife.</div>
</div>
<h2>How It Works: The Pipeline</h2>
<p>Every tartan flows through a five-stage pipeline: <strong>hash → derive → mirror → render → ambiance</strong>. Here is what happens at each stage.</p>
<h3>1. Hashing: Username to Entropy</h3>
<p>Your username is lowercased and passed into the <a href="https://en.wikipedia.org/wiki/SHA-256">SHA-256</a> cryptographic hash function via the <code>SubtleCrypto.digest()</code> method from the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API">Web Crypto API</a>. This produces 32 bytes (256 bits) of deterministic, uniformly distributed output. The critical property here is the <a href="https://en.wikipedia.org/wiki/Avalanche_effect">avalanche effect</a>: changing a single character in the input flips, on average, half the bits in the output. <code>octocat</code> and <code>octocot</code> produce entirely different tartans.</p>
<pre><code>"octocat" → toLowerCase() → TextEncoder.encode() → crypto.subtle.digest("SHA-256", ...) → Uint8Array(32)</code></pre>
<p>Since usernames are lowercased before hashing, <code>octocat</code> and <code>Octocat</code> map to the same tartan. This matches GitHub's own case-insensitive username behavior.</p>
<h3>2. Sett Derivation: From Bytes to Stripes</h3>
<p>A tartan's repeating unit is called a <strong>sett</strong>. Dev Tartan carves one out of the SHA-256 hash bytes using modular arithmetic:</p>
<div class="table-wrap">
<table>
<thead>
<tr><th>Hash Byte(s)</th><th>Purpose</th></tr>
</thead>
<tbody>
<tr><td><code>byte[0]</code></td><td>Number of colors: <code>4 + (byte % 3)</code>, yielding 4, 5, or 6 colors</td></tr>
<tr><td><code>bytes[1..6]</code></td><td>Color selection: each byte indexes into a 20-color palette via <code>byte % 20</code></td></tr>
<tr><td><code>bytes[8..13]</code></td><td>Thread counts (stripe widths), bucketed into <strong>thin</strong> (2-6), <strong>medium</strong> (8-16), or <strong>wide</strong> (18-36) based on byte value thresholds</td></tr>
</tbody>
</table>
</div>
<p>Duplicate colors are avoided by bumping the palette index by 7 (a coprime offset relative to the palette size of 20). This ensures even colliding byte values resolve to distinct colors.</p>
<p>Three palettes are available: <strong>Traditional</strong> (20 colors inspired by historical Scottish dye sources, from woad-adjacent navies to lichen-derived golds), <strong>GitHub</strong> (contribution graph greens), and <strong>Microsoft</strong> (the four Windows logo colors and their variants).</p>
<div class="illustration">
<svg width="400" height="50" viewBox="0 0 400 50" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="130" height="50" fill="#1c2541"/>
<rect x="130" y="0" width="24" height="50" fill="#8b1a1a"/>
<rect x="154" y="0" width="72" height="50" fill="#1a472a"/>
<rect x="226" y="0" width="18" height="50" fill="#c5a041"/>
<rect x="244" y="0" width="24" height="50" fill="#8b1a1a"/>
<rect x="268" y="0" width="132" height="50" fill="#1c2541"/>
<text x="65" y="30" text-anchor="middle" fill="#f0e8d0" font-size="11" font-family="monospace">wide (36)</text>
<text x="142" y="30" text-anchor="middle" fill="#f0e8d0" font-size="9" font-family="monospace" transform="rotate(-90,142,30)">thin</text>
<text x="190" y="30" text-anchor="middle" fill="#f0e8d0" font-size="11" font-family="monospace">medium (12)</text>
<text x="235" y="30" text-anchor="middle" fill="#2c1810" font-size="9" font-family="monospace" transform="rotate(-90,235,30)">thin</text>
</svg>
<p class="illustration-caption">A four-color sett: Dark Navy, Crimson, Hunter Green, Gold — each stripe's width is derived from a hash byte</p>
</div>
<h3>3. Symmetry: The Mirror Trick</h3>
<p>Real tartans use <strong>reflective symmetry</strong>: the sett plays forward and then reverses, creating a palindromic stripe sequence. Given stripes <code>[A, B, C, D]</code>, the rendered sequence becomes:</p>
<pre><code>A B C D C B A B C D C B A ...
└──forward──┘ └─reverse─┘ └──forward──┘</code></pre>
<p>The reversal omits the first and last elements to avoid doubled stripes at the pivot points. This is the same technique used in traditional tartan weaving. If you have ever reversed a linked list in a coding interview, congratulations: you were unknowingly training to weave tartan.</p>
<div class="illustration">
<svg width="420" height="60" viewBox="0 0 420 60" xmlns="http://www.w3.org/2000/svg">
<!-- Forward: A B C D -->
<rect x="0" y="0" width="70" height="44" fill="#1c2541"/>
<rect x="70" y="0" width="30" height="44" fill="#8b1a1a"/>
<rect x="100" y="0" width="50" height="44" fill="#1a472a"/>
<rect x="150" y="0" width="20" height="44" fill="#c5a041"/>
<!-- Reverse: C B -->
<rect x="170" y="0" width="50" height="44" fill="#1a472a"/>
<rect x="220" y="0" width="30" height="44" fill="#8b1a1a"/>
<!-- Forward: A B C D -->
<rect x="250" y="0" width="70" height="44" fill="#1c2541"/>
<rect x="320" y="0" width="30" height="44" fill="#8b1a1a"/>
<rect x="350" y="0" width="50" height="44" fill="#1a472a"/>
<rect x="400" y="0" width="20" height="44" fill="#c5a041"/>
<!-- Stripe labels -->
<text x="35" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">A</text>
<text x="85" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">B</text>
<text x="125" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">C</text>
<text x="160" y="27" text-anchor="middle" fill="#2c1810" font-size="15" font-family="serif" font-weight="bold">D</text>
<text x="195" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">C</text>
<text x="235" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">B</text>
<text x="285" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">A</text>
<text x="335" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">B</text>
<text x="375" y="27" text-anchor="middle" fill="#f0e8d0" font-size="15" font-family="serif" font-weight="bold">C</text>
<text x="410" y="27" text-anchor="middle" fill="#2c1810" font-size="15" font-family="serif" font-weight="bold">D</text>
<!-- Bracket labels -->
<line x1="0" y1="50" x2="170" y2="50" stroke="#c5a041" stroke-width="2"/>
<line x1="170" y1="50" x2="250" y2="50" stroke="#8b774b" stroke-width="2" stroke-dasharray="4,3"/>
<line x1="250" y1="50" x2="420" y2="50" stroke="#c5a041" stroke-width="2"/>
<text x="85" y="59" text-anchor="middle" fill="#6b5240" font-size="9" font-family="serif" font-style="italic">forward</text>
<text x="210" y="59" text-anchor="middle" fill="#6b5240" font-size="9" font-family="serif" font-style="italic">reverse</text>
<text x="335" y="59" text-anchor="middle" fill="#6b5240" font-size="9" font-family="serif" font-style="italic">forward</text>
</svg>
<p class="illustration-caption">The sett mirrors to create a palindromic stripe sequence — no doubled pivots</p>
</div>
<h3>4. Rendering: Warp, Weft, and SVG Rectangles</h3>
<p>Real tartan is a <strong>2/2 twill weave</strong>: warp threads (vertical) and weft threads (horizontal) interlace at right angles. Dev Tartan simulates this using layered SVG <code><rect></code> elements:</p>
<ol>
<li><strong>Background fill:</strong> the first color of the sett floods the 500x500 SVG canvas</li>
<li><strong>Warp stripes:</strong> vertical rectangles at 90% opacity</li>
<li><strong>Weft stripes:</strong> horizontal rectangles at 55% opacity with <code>mix-blend-mode: multiply</code>, simulating thread crossings where colors optically blend</li>
<li><strong>Twill texture overlay:</strong> a tiny 4x4px repeating SVG <code><pattern></code> of alternating semi-transparent light/dark squares, mimicking the diagonal twill ridges visible in real woven cloth</li>
</ol>
<p>The sett is scaled so that roughly three full repeats tile across the canvas. Each stripe's pixel width is computed from its thread count, multiplied by a scale factor derived from the total sett width.</p>
<div class="illustration">
<div class="illustration-row">
<div>
<svg width="140" height="140" viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg">
<rect width="140" height="140" fill="#1c2541"/>
<g opacity="0.9">
<rect x="0" y="0" width="36" height="140" fill="#1c2541"/>
<rect x="36" y="0" width="10" height="140" fill="#8b1a1a"/>
<rect x="46" y="0" width="24" height="140" fill="#1a472a"/>
<rect x="70" y="0" width="6" height="140" fill="#c5a041"/>
<rect x="76" y="0" width="24" height="140" fill="#1a472a"/>
<rect x="100" y="0" width="10" height="140" fill="#8b1a1a"/>
<rect x="110" y="0" width="30" height="140" fill="#1c2541"/>
</g>
</svg>
<p class="illustration-label">Warp (vertical)</p>
</div>
<div class="illustration-op">+</div>
<div>
<svg width="140" height="140" viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg">
<rect width="140" height="140" fill="#1c2541"/>
<g opacity="0.55">
<rect x="0" y="0" width="140" height="36" fill="#1c2541"/>
<rect x="0" y="36" width="140" height="10" fill="#8b1a1a"/>
<rect x="0" y="46" width="140" height="24" fill="#1a472a"/>
<rect x="0" y="70" width="140" height="6" fill="#c5a041"/>
<rect x="0" y="76" width="140" height="24" fill="#1a472a"/>
<rect x="0" y="100" width="140" height="10" fill="#8b1a1a"/>
<rect x="0" y="110" width="140" height="30" fill="#1c2541"/>
</g>
</svg>
<p class="illustration-label">Weft (horizontal)</p>
</div>
<div class="illustration-op">=</div>
<div>
<svg width="140" height="140" viewBox="0 0 140 140" xmlns="http://www.w3.org/2000/svg">
<rect width="140" height="140" fill="#1c2541"/>
<g opacity="0.9">
<rect x="0" y="0" width="36" height="140" fill="#1c2541"/>
<rect x="36" y="0" width="10" height="140" fill="#8b1a1a"/>
<rect x="46" y="0" width="24" height="140" fill="#1a472a"/>
<rect x="70" y="0" width="6" height="140" fill="#c5a041"/>
<rect x="76" y="0" width="24" height="140" fill="#1a472a"/>
<rect x="100" y="0" width="10" height="140" fill="#8b1a1a"/>
<rect x="110" y="0" width="30" height="140" fill="#1c2541"/>
</g>
<g opacity="0.55" style="mix-blend-mode:multiply">
<rect x="0" y="0" width="140" height="36" fill="#1c2541"/>
<rect x="0" y="36" width="140" height="10" fill="#8b1a1a"/>
<rect x="0" y="46" width="140" height="24" fill="#1a472a"/>
<rect x="0" y="70" width="140" height="6" fill="#c5a041"/>
<rect x="0" y="76" width="140" height="24" fill="#1a472a"/>
<rect x="0" y="100" width="140" height="10" fill="#8b1a1a"/>
<rect x="0" y="110" width="140" height="30" fill="#1c2541"/>
</g>
</svg>
<p class="illustration-label">Combined tartan</p>
</div>
</div>
<p class="illustration-caption">Warp and weft layers combine with <code>mix-blend-mode: multiply</code> to simulate thread crossings</p>
</div>
<h3>5. Ambiance: Background Tartanification</h3>
<p>After rendering, a miniature version of your tartan is serialized as a <code>data:</code> URI SVG tile (160x160px) with very low opacity (6-8%) and set as the page's repeating <code>background-image</code>. The entire viewport becomes subtly tartanified.</p>
<h2>Clan Tartans</h2>
<p>If your GitHub username matches one of 106 real Scottish clan names, Dev Tartan renders the <strong>authentic clan tartan</strong> instead of generating one from the hash. Sett definitions were sourced from public-domain tartan registries, principally the <a href="https://www.tartanregister.gov.uk/">Scottish Register of Tartans</a> and cross-referenced with the <a href="https://www.tartansauthority.com/">Scottish Tartans Authority</a>.</p>
<p>Each sett is encoded as a compact string of standard tartan weaving abbreviations and thread counts (e.g., <code>R 72 B 8 BK 12 Y 2</code>). The lookup is case-insensitive and supports common alternate spellings: <code>Mc</code> prefixes resolve to <code>Mac</code>, <code>Stuart</code> resolves to Stewart Royal, <code>Ogilvie</code> to Ogilvy, and so on.</p>
<h2>The Bagpipe Synthesizer</h2>
<p>Every username also gets a unique, deterministic bagpipe tune synthesized entirely in the browser via the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API">Web Audio API</a>. The audio graph looks like this:</p>
<ul>
<li><strong>Three drone pipes</strong> (bass, tenor, alto) built from pairs of detuned <code>OscillatorNode</code>s with sawtooth and triangle waveforms, producing the sustained harmonic drone characteristic of Highland bagpipes</li>
<li><strong>A chanter melody</strong> derived from your username hash, using a pentatonic scale. Hash bytes select note indices, durations, and ornament patterns (grace notes, doublings, throws) from the Piobaireachd tradition</li>
<li><strong>Breath noise</strong> modeled with a white noise buffer filtered through a <code>BiquadFilterNode</code> (bandpass, 800 Hz center) and amplitude-modulated at 0.3 Hz to simulate the cyclic pressure of a bag under the piper's arm</li>
<li><strong>Convolution reverb</strong> synthesized from a procedurally generated impulse response, adding a sense of acoustic space</li>
</ul>
<p>The tune can be downloaded as a 16-bit PCM WAV file, rendered offline via <code>OfflineAudioContext</code>.</p>
<h2>The Invertocat</h2>
<p>The GitHub Invertocat logo in the header is not a static image. It is an SVG <code><clipPath></code> filled with a dynamically generated tartan <code><pattern></code>. When you generate a tartan, the Invertocat updates to wear your tartan as its fill. The clip path uses the official Invertocat SVG path data from <a href="https://github.com/logos">GitHub's logo page</a>.</p>
<h2>The Character</h2>
<p>After generating a tartan, a small procedurally generated SVG character appears wearing your tartan as a kilt. The character's features (skin tone, hair color, hair style, eye color, and expression) are derived from later bytes in the SHA-256 hash, making each character as deterministic and unique as the tartan itself.</p>
<h2>Technical Constraints</h2>
<ul>
<li><strong>Zero dependencies.</strong> The entire application is a single HTML file. No npm packages, no bundler, no transpiler, no framework. Every line of CSS and JavaScript lives inline.</li>
<li><strong>No server.</strong> All computation runs client-side. The only network request is an optional call to the GitHub Events API to populate the gallery of recently active developers.</li>
<li><strong>Deterministic output.</strong> Given the same username and palette, the tartan, character, and bagpipe tune are identical on every run, on every browser, on every device. This is a pure function of SHA-256.</li>
<li><strong>~2,700 lines.</strong> That is the entire codebase. HTML structure, CSS styling, SVG rendering, audio synthesis, 106 clan tartan definitions, and a procedural character generator, all in one file.</li>
</ul>
<h2>The Numbers</h2>
<ul>
<li>SHA-256 produces 2<sup>256</sup> possible hashes, which is roughly 1.16 x 10<sup>77</sup>. That is more possible tartans than there are atoms in the observable universe.</li>
<li>The traditional palette has 20 colors. With 4-6 colors per sett and 3 width buckets per stripe, the combinatorial space is enormous even before the hash enters the picture.</li>
<li>The 4x4 twill overlay pattern contains 16 sub-cells, alternating between <code>rgba(255,255,255,0.03)</code> and <code>rgba(0,0,0,0.04)</code>, faithfully approximating the diagonal ridge pattern of a 2/2 twill weave at pixel scale.</li>
</ul>
<h2>Colophon</h2>
<p>Dev Tartan was built entirely with <a href="https://github.com/features/copilot/cli">GitHub Copilot CLI</a>. The typeface is <a href="https://github.com/github/mona-sans">Mona Sans</a>, GitHub's variable font (weights 200–900), loaded via Fontsource CDN with <code>font-display: swap</code> to avoid layout shift. The color scheme is inspired by aged parchment and Scottish earth tones.</p>
<p>Source code is on <a href="https://github.com/leereilly/dev-tartan">GitHub</a>. Licensed under <a href="https://github.com/leereilly/dev-tartan/blob/main/LICENSE">MIT</a>.</p>
</div>
<footer>
<p>Woven with bits & bytes • SHA-256 → Sett</p>
<p><a href="https://github.com/leereilly/dev-tartan">Source on GitHub</a> • Built with <a href="https://github.com/features/copilot">GitHub Copilot CLI</a></p>
</footer>
<script>
// Theme toggle — default to light mode, persist choice in localStorage
(function() {
const toggle = document.getElementById('theme-toggle');
const stored = localStorage.getItem('dev-tartan-theme');
if (stored === 'dark') document.body.classList.add('dark-mode');
toggle.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
const isDark = document.body.classList.contains('dark-mode');
localStorage.setItem('dev-tartan-theme', isDark ? 'dark' : 'light');
});
})();
</script>
</body>
</html>