Dev Tartan

About Dev Tartan

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.

It was built entirely using GitHub Copilot CLI for the GitHub Copilot CLI Coding Challenge.

What Are Tartans and Kilts?

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 sett, 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.

Lee wearing a kilt at his wedding with his wife Michelle
Me in a kilt getting married to my smokin' hot wife.

How It Works: The Pipeline

Every tartan flows through a five-stage pipeline: hash → derive → mirror → render → ambiance. Here is what happens at each stage.

1. Hashing: Username to Entropy

Your username is lowercased and passed into the SHA-256 cryptographic hash function via the SubtleCrypto.digest() method from the Web Crypto API. This produces 32 bytes (256 bits) of deterministic, uniformly distributed output. The critical property here is the avalanche effect: changing a single character in the input flips, on average, half the bits in the output. octocat and octocot produce entirely different tartans.

"octocat" → toLowerCase() → TextEncoder.encode() → crypto.subtle.digest("SHA-256", ...) → Uint8Array(32)

Since usernames are lowercased before hashing, octocat and Octocat map to the same tartan. This matches GitHub's own case-insensitive username behavior.

2. Sett Derivation: From Bytes to Stripes

A tartan's repeating unit is called a sett. Dev Tartan carves one out of the SHA-256 hash bytes using modular arithmetic:

Hash Byte(s)Purpose
byte[0]Number of colors: 4 + (byte % 3), yielding 4, 5, or 6 colors
bytes[1..6]Color selection: each byte indexes into a 20-color palette via byte % 20
bytes[8..13]Thread counts (stripe widths), bucketed into thin (2-6), medium (8-16), or wide (18-36) based on byte value thresholds

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.

Three palettes are available: Traditional (20 colors inspired by historical Scottish dye sources, from woad-adjacent navies to lichen-derived golds), GitHub (contribution graph greens), and Microsoft (the four Windows logo colors and their variants).

wide (36) thin medium (12) thin

A four-color sett: Dark Navy, Crimson, Hunter Green, Gold — each stripe's width is derived from a hash byte

3. Symmetry: The Mirror Trick

Real tartans use reflective symmetry: the sett plays forward and then reverses, creating a palindromic stripe sequence. Given stripes [A, B, C, D], the rendered sequence becomes:

A  B  C  D  C  B  A  B  C  D  C  B  A  ...
└──forward──┘  └─reverse─┘  └──forward──┘

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.

A B C D C B A B C D forward reverse forward

The sett mirrors to create a palindromic stripe sequence — no doubled pivots

4. Rendering: Warp, Weft, and SVG Rectangles

Real tartan is a 2/2 twill weave: warp threads (vertical) and weft threads (horizontal) interlace at right angles. Dev Tartan simulates this using layered SVG <rect> elements:

  1. Background fill: the first color of the sett floods the 500x500 SVG canvas
  2. Warp stripes: vertical rectangles at 90% opacity
  3. Weft stripes: horizontal rectangles at 55% opacity with mix-blend-mode: multiply, simulating thread crossings where colors optically blend
  4. Twill texture overlay: a tiny 4x4px repeating SVG <pattern> of alternating semi-transparent light/dark squares, mimicking the diagonal twill ridges visible in real woven cloth

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.

Warp (vertical)

+

Weft (horizontal)

=

Combined tartan

Warp and weft layers combine with mix-blend-mode: multiply to simulate thread crossings

5. Ambiance: Background Tartanification

After rendering, a miniature version of your tartan is serialized as a data: URI SVG tile (160x160px) with very low opacity (6-8%) and set as the page's repeating background-image. The entire viewport becomes subtly tartanified.

Clan Tartans

If your GitHub username matches one of 106 real Scottish clan names, Dev Tartan renders the authentic clan tartan instead of generating one from the hash. Sett definitions were sourced from public-domain tartan registries, principally the Scottish Register of Tartans and cross-referenced with the Scottish Tartans Authority.

Each sett is encoded as a compact string of standard tartan weaving abbreviations and thread counts (e.g., R 72 B 8 BK 12 Y 2). The lookup is case-insensitive and supports common alternate spellings: Mc prefixes resolve to Mac, Stuart resolves to Stewart Royal, Ogilvie to Ogilvy, and so on.

The Bagpipe Synthesizer

Every username also gets a unique, deterministic bagpipe tune synthesized entirely in the browser via the Web Audio API. The audio graph looks like this:

The tune can be downloaded as a 16-bit PCM WAV file, rendered offline via OfflineAudioContext.

The Invertocat

The GitHub Invertocat logo in the header is not a static image. It is an SVG <clipPath> filled with a dynamically generated tartan <pattern>. 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 GitHub's logo page.

The Character

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.

Technical Constraints

The Numbers

Colophon

Dev Tartan was built entirely with GitHub Copilot CLI. The typeface is Mona Sans, GitHub's variable font (weights 200–900), loaded via Fontsource CDN with font-display: swap to avoid layout shift. The color scheme is inspired by aged parchment and Scottish earth tones.

Source code is on GitHub. Licensed under MIT.