roulette-lite

Procedural roulette-wheel illustrations as an SVG string — seeded geometry, a brand-aware auto-palette, line or flat, top or tilted, an optional CSS spin.

Available on: npm GitHub Project site

roulette-lite draws a roulette wheel by code. One call returns an SVG string — in Node at build time or in the browser — so a static site gets its hero art with no script on the page. seed spins the geometry, brand spins the colours: red, black and a green zero stay a roulette's, and your brand fills them. A procedural roulette wheel in SVG with zero dependencies, 7.4 KB gzipped.

What it draws

  • The wheel — Roulette.svg(): flat colour with volume or line art, seen from above (view: 'top') or in three-quarter view ('tilt'), European (37 pockets) or American (38). detail: 1 keeps the silhouette, 2 adds frets, deflectors and grain.
  • The mark — Roulette.mark() reduces the wheel to what reads at 16 px: a rim, one ring of segments, a hub. A wheel logo and favicon in one call — mono in currentColor, or badge on a backplate.
  • The table — Roulette.table() draws the roulette betting layout, 14:5, as a hero band the wheel can stand on: the real 12 × 3 grid, dozens, column bets and the six outside boxes, with the canonical irregular red/black pattern and no digits.

How to use it

Install with npm install roulette-lite. A <script> gets the global Roulette, Node and bundlers get module.exports. At build time Roulette.svg({ seed: 'example.com', brand: '#7c5cff' }) returns markup to inline into an Astro page or any static generator; in the browser Roulette.init('#hero-art', { seed: 42, motion: true }) draws into an element and sleeps while it is off screen. The SVG has a viewBox and a square frame by default, so every wheel fits the same CSS. motion: true turns the wheel one way and the ball the other, as CSS inside the SVG; prefers-reduced-motion: reduce stops every animation.

Colour

You pass one to three brand colours, and a brand-aware auto-palette assigns them: each takes the role nearest its hue — red pockets, the green zero, brass — the first colour left over becomes the body (the rim) and a second one the bowl. A role no colour took gets its classic hue in your brand's key, and black is always derived. Any role can be pinned with any CSS colour, including a custom property, so an inline wheel follows a light/dark toggle with no script. Roulette.palette() returns the derived colours for either theme.

Licence and stability

The output for a given seed and options is byte-identical, and a seed is independent of the brand: change the colours and the geometry does not move. Within a minor version the output does not change; any change is a minor release with a changelog line. Nothing in the output names the library. MIT © 301ST, built for spintax.net.