The tech cloud uses a deterministic layout algorithm to place tokens in a free-form, organic-looking arrangement that remains stable across page refreshes.
- Each token from
content/tech-bits.jsonhas asizeproperty (e.g.,sm,base,lg,xl,2xl,3xl,4xl,5xl) - The script maps these to CSS
--text-*tokens - Text dimensions are measured using an offscreen canvas with the same font family
- Tokens are sorted by
sizeRank(largest first) so big words don't get trapped behind smaller ones
- No randomness: Uses hash-based seeding for reproducibility
- Hash function: FNV1a hash of each token's text string
- Base position: Halton sequence (bases 2 and 3) provides well-distributed initial coordinates
- Jitter: Small offsets derived from the hash create organic spread:
jitterX = (hashToUnit(hash + 17) - 0.5) * originjitterY = (hashToUnit(hash + 29) - 0.5) * originstartAngle = hashToUnit(hash + 43) * Math.PI * 2
- For each token, attempts up to 520 spiral steps using the golden angle (2.399963229728653)
- Each candidate position is:
- Clamped to stay within padded container bounds
- Checked against all previously placed tokens
- Uses a configurable
gapbuffer to prevent overlaps
- If no valid position found in spiral, falls back to best clamped position
- Padding and gap scale with container size:
pad = min(max(width, height) * 0.08, 60)gap = min(max(width, height) * 0.02, 18)
- Prevents overlap when container is larger
- Maintains spacing on smaller screens
- On window resize, the same deterministic algorithm runs again
- Same hash seeds = same relative positions
- Layout adapts to new container dimensions without randomness
- Inspect token properties in console:
w,h,hash,left,top - Check collision detection: temporarily log
intersects()results - Adjust spacing: modify
pad,gap, or spiral step count/radius - Verify measurements: ensure canvas font matches rendered font
hashString(): Generates deterministic hash from texthalton(): Low-discrepancy sequence for base positionsmeasureText(): Canvas-based text dimension measurementintersects(): Collision detection between bounding boxeslayoutTechCloud(): Main layout orchestrator
To make the spiral text larger and easier to read:
-
Text size – In
style.css, bump the:roottext tokens:--text-sm,--text-base,--text-lg,--text-xl,--text-2xl,--text-3xl,--text-4xl,--text-5xl- Example:
--text-sm: 1rem;--text-base: 1.2rem;… up to--text-5xl: 5rem;(or higher).
-
Canvas / container size – In
style.css:.tech-cloud { min-height: 800px; }(or more) to give the spiral more room..content-section { max-width: 1400px; }if you want a wider section.
-
Spiral scale – In
script/tech-cloud.js, insidegetSpiralPoint():- Change
const a = minDimension * 0.05;to e.g.0.07or0.1so the spiral starts farther out and words sit in a larger ring.
- Change
-
User zoom – Use the new − and + buttons (top-left of the tech cloud) to zoom out/in; default zoom is 1.25×.