import { useMemo, useState } from 'react' import { Blobatar } from '@blobatar/react' import { IconCopy } from '@tabler/icons-react' import { traits as createTraits } from 'blobatar' import type { Palette, TraitOverrides } from 'blobatar' import { Link } from 'wouter' import { Button } from '@/client/components/ui/button' import { Input } from '@/client/components/ui/input' import { Slider } from '@/client/components/ui/slider' const AGENT_SEED = 'moi-agent' const AGENT_PALETTE = { head: 'var(--primary)', eye: 'var(--primary-foreground)' } satisfies Palette // Static Blobatars render as images, where app CSS variables are unavailable. const STATIC_AGENT_PALETTE = { head: '#171717', eye: '#fafafa' } satisfies Palette const SHAPE_FAMILIES = [ { name: 'round', value: 0.11, from: 0, to: 0.22 }, { name: 'organic', value: 0.35, from: 0.22, to: 0.48 }, { name: 'boxy', value: 0.54, from: 0.48, to: 0.6 }, { name: 'capsule', value: 0.65, from: 0.6, to: 0.7 }, { name: 'nub', value: 0.745, from: 0.7, to: 0.79 }, { name: 'cloud', value: 0.825, from: 0.79, to: 0.86 }, { name: 'droplet', value: 0.887, from: 0.86, to: 0.915 }, { name: 'hexagon', value: 0.932, from: 0.915, to: 0.95 }, { name: 'sun', value: 0.965, from: 0.95, to: 0.98 }, { name: 'triangle', value: 0.99, from: 0.98, to: 1 } ] as const type ShapeFamily = (typeof SHAPE_FAMILIES)[number] type ShapeName = ShapeFamily['name'] type TraitControl = { key: string label: string range: string } const BASE_TRAITS: readonly TraitControl[] = [ { key: 'body.r', label: 'Body size', range: '31–38 px before family scaling' }, { key: 'body.ratio', label: 'Aspect ratio', range: '0.92–1.08× height' } ] const ORGANIC_TRAITS: readonly TraitControl[] = [ { key: 'body.pts', label: 'Outline points', range: '6–8 points' }, ...Array.from({ length: 8 }, (_, index) => ({ key: `body.r${index}`, label: `Point ${index + 1} radius`, range: '0.84–1.16× radius' })) ] const FAMILY_TRAITS = { round: [{ key: 'body.n', label: 'Roundness', range: '1.9–2.5 superellipse' }], organic: ORGANIC_TRAITS, boxy: [ { key: 'body.n', label: 'Boxiness', range: '3.4–6 superellipse' }, { key: 'body.rot', label: 'Rotation', range: '−20–20°' } ], capsule: [{ key: 'capsule.squat', label: 'Squat', range: '0.55–0.68× height' }], nub: [ { key: 'body.n', label: 'Roundness', range: '1.9–2.5 superellipse' }, { key: 'nub.n', label: 'Nub count', range: '1–2 nubs' }, { key: 'nub.a0', label: 'Nub 1 angle', range: '0–360°' }, { key: 'nub.r0', label: 'Nub 1 size', range: '0.24–0.4× radius' }, { key: 'nub.a1', label: 'Nub 2 angle', range: '0–360°' }, { key: 'nub.r1', label: 'Nub 2 size', range: '0.24–0.4× radius' } ], cloud: [ ...ORGANIC_TRAITS, { key: 'cloud.n', label: 'Lobe count', range: '4–6 lobes' }, ...Array.from({ length: 6 }, (_, index) => ({ key: `cloud.r${index}`, label: `Lobe ${index + 1} size`, range: '0.44–0.62× radius' })) ], droplet: [{ key: 'droplet.tip', label: 'Tip length', range: '1.4–1.65× radius' }], hexagon: [ { key: 'body.rot', label: 'Rotation', range: '−12–12°' }, { key: 'poly.round', label: 'Corner roundness', range: '0.24–0.5' } ], sun: [ { key: 'body.n', label: 'Center roundness', range: '1.9–2.5 superellipse' }, { key: 'sun.n', label: 'Ray count', range: '6–9 rays' }, { key: 'sun.dist', label: 'Ray distance', range: '1–1.08× radius' }, { key: 'sun.r', label: 'Ray size', range: '0.2–0.26× radius' }, { key: 'sun.rot', label: 'Ray rotation', range: '0–360°' } ], triangle: [ { key: 'body.rot', label: 'Rotation', range: '−5–5°' }, { key: 'poly.round', label: 'Corner roundness', range: '0.24–0.5' } ] } satisfies Record function clampTrait(value: number): number { return Math.min(0.999, Math.max(0, Math.round(value * 1000) / 1000)) } function formatTrait(value: number): string { return value.toFixed(3) } function singleSliderValue(value: number | readonly number[]): number { return typeof value === 'number' ? value : (value[0] ?? 0) } type ShapePreviewProps = { animated?: boolean geometry?: TraitOverrides seed: string size: number shape: number } function ShapePreview({ animated = false, geometry, seed, size, shape }: ShapePreviewProps) { return ( ) } type TraitSliderProps = { control: TraitControl overridden: boolean value: number onChange: (value: number) => void } function TraitSlider({ control, overridden, value, onChange }: TraitSliderProps) { const inputId = `trait-${control.key.replaceAll('.', '-')}` return (
{ const next = event.currentTarget.valueAsNumber if (!Number.isNaN(next)) onChange(clampTrait(next)) }} className="w-24 font-mono tabular-nums" />
onChange(clampTrait(singleSliderValue(next)))} /> {control.range} {overridden && ' · overridden'}
) } export function BlobatarShapesPage() { const [seed, setSeed] = useState(AGENT_SEED) const [shapeName, setShapeName] = useState('boxy') const [geometry, setGeometry] = useState>({}) const seededTraits = useMemo(() => createTraits(seed), [seed]) const family = SHAPE_FAMILIES.find(candidate => candidate.name === shapeName) ?? SHAPE_FAMILIES[2] const shape = family.value const familyControls = FAMILY_TRAITS[family.name] const activeKeys = new Set([...BASE_TRAITS, ...familyControls].map(control => control.key)) const activeGeometry = Object.fromEntries( Object.entries(geometry).filter(([key]) => activeKeys.has(key)) ) const configText = JSON.stringify( { name: seed, traits: { shape, ...activeGeometry } }, null, 2 ) const traitValue = (key: string) => geometry[key] ?? seededTraits(key) const setTrait = (key: string, value: number) => { setGeometry(current => ({ ...current, [key]: value })) } return (
← Dev pages

Playground

Blobatar shape builder

Blobatar has 10 silhouette families. The seed generates every geometry trait you leave alone, which is why different names produce so many variations. Pick a family and tune its normalized 0–1 traits here.

Shape family

Values within one family band select the same silhouette. These are stable representative values for each family.

{SHAPE_FAMILIES.map(candidate => ( ))}

Base geometry

Sliders start at values generated by the seed. Moving one creates an explicit trait override.

{BASE_TRAITS.map(control => ( setTrait(control.key, value)} /> ))}

{family.name} geometry

These controls only affect the selected family.

{familyControls.map(control => ( setTrait(control.key, value)} /> ))}
) }