Styles / Beastie Preview
Meet the Beasties.
Beasties grew in the Grid's dark corners, where the dots went unswept: one eye or three, fangs, horns, stalks and wings. They're friendlier than they look, and they never forget a face. Give one some text and it draws the same monster every time, on any machine, with nothing stored. Type anything to meet yours.
Below 40px it switches to a simpler version of the same Beastie.
Same options, more seeds
Use it
Install
npm install seedkin
pnpm add seedkin
yarn add seedkin
bun add seedkin
Draw one
import { beastie, beastieDataUri } from 'seedkin/beastie';
// An SVG string, to inline
const svg = beastie(user.id);
// A data: URI, for an img src or CSS url()
const src = beastieDataUri(user.id, { size: 40 });
import { beastieDataUri } from 'seedkin/beastie';
export function Avatar({ id, size = 40 }) {
return <img src={beastieDataUri(id, { size, title: null })} alt="" width={size} height={size} />;
}
<img data-seed="ada" alt="" width="48" height="48" />
<script type="module">
import { beastieDataUri } from 'https://cdn.jsdelivr.net/npm/seedkin@2/dist/styles/beastie/index.js';
for (const img of document.querySelectorAll('img[data-seed]')) {
img.src = beastieDataUri(img.dataset.seed, { size: img.width, title: null });
}
</script>
import { beastie } from 'seedkin/beastie';
// GET /avatar/:id, as an image any page can use
export async function GET(_request, { params }) {
const { id } = await params;
return new Response(beastie(id, { size: 96 }), {
headers: { 'Content-Type': 'image/svg+xml', 'Cache-Control': 'public, max-age=31536000, immutable' },
});
}
Details
- Entry point
seedkin/beastie- Status
- Preview A seed's avatar can change in a minor version until it's stable. What Preview means
- Size
- 7.3 kB gzipped, with no dependencies
- Parts
- 5 bodies, 5 eyes, 5 mouths, 4 tops, 2 side pieces, 8 palettes, on 4 cell shapes
- Small sizes
- A simpler 9x9 monster below 40px, from the same traits
- Licence
- MIT, art included
Options
| Option | Type | Default | What it does |
|---|---|---|---|
shape | 'square' | 'circle' | 'triangle' | 'diamond' | picked by the seed | Cell shape. |
palette | number | Palette | picked by the seed | Index into Beastie's PALETTES (its hides), or a palette object. |
size | number | 96 | Width and height in pixels. |
detail | 'auto' | 'full' | 'small' | 'auto' | 'small' is the simpler 9x9 monster; 'auto' draws it below 40px. |
showGrid | boolean | 'auto' | 'auto' | Draw the empty grid cells; 'auto' draws them from 40px up. |
look | 'gapped' | 'flat' | 'inked' | 'soft' | 'soft-inked' | 'sticker' | 'gapped' | How the cells are drawn: apart, or merged into flat shapes. See Looks. |
frame | 'square' | 'rounded' | 'squircle' | 'circle' | 'square' | The outline of the background. Outside it the image is transparent. |
background | boolean | true | Draw the palette's background. |
title | string | null | 'Monster avatar' | Accessible name. null marks the image decorative. |