8000 GitHub - bolechen/doodles-faces: Type a name. Get a graphite doodle. Same name, same face. Pure canvas + TS, no AI. · GitHub
[go: up one dir, main page]

Skip to content

About

Type a name. Get a graphite doodle. Same name, same face. Pure canvas + TS, no AI.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

doodles faces

Type a name. Get a graphite doodle. Same name, same face.

A seeded face generator drawn entirely in the browser. Type any username and you get a unique hand-drawn face: a wobbly skull, solid ink hair, tired eyes, and the occasional eye patch or visor. Same name always produces the same face.

No AI. No image assets. Just canvas, TypeScript, and a seeded random number generator.

→ Try it live: doodlefaces.site


Why

Mannay once said "you can just draw faces with javascript" and shared sketchbook after sketchbook of faces that were pure code. This is an independent, clean-room take on that technique: features are painter functions, assembled onto a rough 3D skull, roughed up with a graphite stroke engine.

What makes it fun

  • A name is a seed. Share ?u=ada and everyone sees the same ada.
  • Mix two people with ?u=ada&with=bob: a blended face that inherits traits from both, shareable as an ada × bob card.
  • Crowd view renders a 5×3 sheet; click any cell and that person changes.
  • Every face comes with a trait caption (gaunt · round · none · seam).

Features

Mode What it does
Portrait One graphite head from a username (?u=name)
Mix A blended face from two names (?u=a&with=b)
Crowd A 5×3 sheet of faces from one seed (?view=crowd)
Share Web Share API with a 1200×630 PNG card, or a copyable link
Save Download the card or the crowd sheet as PNG

Tech

  • Seeded RNG — mulberry32 + FNV-1a hash. Deterministic, no network.
  • 3D skull pinning — features live on a rough head and follow yaw/pitch instead of sliding around in 2D.
  • Graphite engine — ribbon strokes with variable width, dry granulation, paper grain, and muted color washes. Everything is drawn, nothing is loaded.
  • Dynamic OG — /api/og?u=name renders the real graphite face server-side (@napi-rs/canvas, node runtime, bundled Andale Mono font for Linux) for social previews. Same name, same face, same card.

Dev

pnpm i
pnpm dev
pnpm test          # determinism + src/_lib sync

Build / Deploy

pnpm build            # typecheck + vite build into dist/
pnpm dlx vercel --prod        # Vercel (with the dynamic /api/og endpoint)
# or
npx wrangler deploy           # Cloudflare Workers (static assets only)

Static output lives in dist/; the app itself is 100% client-side and identical on either host. The two deploy targets differ only in the OG endpoint:

  • Vercel (vercel.json) — installs with pnpm, publishes dist/, and runs api/og.ts as a Node function (@napi-rs/canvas, runtime "nodejs") for a per-username dynamic social card.
  • Cloudflare Workers (wrangler.jsonc) — static assets only (assets.directory: dist, SPA fallback to index.html); @napi-rs/canvas is a native N-API addon and cannot run in the Workers V8 isolate, so api/og.ts is not deployed here. Social previews fall back to the static public/og.png. public/_headers carries the security headers that vercel.json's headers block sets on Vercel.

Layout

api/
  og.ts        dynamic social card per username (serverless)
public/
  og.png       static fallback, icons, robots.txt, sitemap.xml
src/
  types.ts     Face DNA
  rng.ts       mulberry32 + FNV hash
  geom.ts      3D projection, pin-to-skull, path smoothing
  ink.ts       graphite stroke, paper, grain, washes
  face.ts      seed → traits
  draw.ts      painters, share card, crowd sheet
  main.ts      desk UI + i18n-ready strings

License

MIT — do whatever you want. A credit link back is always appreciated.

About

Type a name. Get a graphite doodle. Same name, same face. Pure canvas + TS, no AI.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0