GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - investblog/dice-lite: A procedural throw of dice as an SVG string. Seeded placement and values, brand-aware table palette, paper or frosted-glass bodies, an optional CSS roll. Zero dependencies; runs in Node at build time and in the browser.

BranchesTags
Open more actions menu

Latest commit

 

History

33 Commits
33 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
scripts
scripts
 
 
test
test
 
 
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
RELEASING.md
RELEASING.md
 
 
dice.d.ts
dice.d.ts
 
 
dice.js
dice.js
 
 
eslint.config.js
eslint.config.js
 
 
index.html
index.html
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

dice-lite

A throw of dice on a table, drawn 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. Two knobs span the variant space: seed throws the dice (how many, where they lie, what they show), brand colours the table.

Each die is a rounded cube projected at runtime from its own seeded orientation: three visible faces, exact projected pips, opposite sides summing to seven by construction, every face corner rounded. Two bodies behind one option — paper, the classic white die, or frosted glass, the dice showing through each other. A result such as a lucky seven is a named preset that places values; nothing is ever scored. Zero dependencies, ~9 KB minified and gzipped.

npm license

Live demo → — the throw's options on controls: seed stepping, a 24-seed contact sheet, every result, and the six faces.

Three frosted-glass dice on a bare hexagon lattice, the back die showing through the front two

The picture above is one call, byte for byte — glass dice on the bare table:

const Dice = require('@spintax/dice-lite');

Dice.toss({
  seed: 'spintax.net', theme: 'light', style: 'flat',
  body: 'glass', felt: 'transparent', rail: 'transparent', size: 960,
});
// → '<svg xmlns="http://www.w3.org/2000/svg" viewBox="…" …>…</svg>'

Dice.toss({
  seed: 'hero',            // a string or a 32-bit number; the default is 1
  brand: ['#00abf3', '#d6af3c', '#a91455'], // #hex or rgb(), one or a list — the site's tokens
  theme: 'dark',           // 'dark' | 'light'
  body: 'paper',           // 'paper' | 'glass'
  rail: 'auto',            // 'auto' dark surround | 'brand' | 'felt' | any colour
  dice: 3,                 // 2–5; appends: dice 0..k-1 of k+1 are the k-dice throw
  result: 'lucky7',        // 'lucky7' | 'snake' | 'boxcars' | 'matched' | 'mixed'
  values: [4, null, 2],    // pin exact top faces; null lets the seed/result decide
  motion: 'roll',          // a one-shot settle; honours prefers-reduced-motion
  size: 960,               // width; the height follows the viewBox
});

Dice.die({ value: 5 });    // one die on its em — an icon
Dice.palette('#c2410c');   // → { felt, rail, trim, die, pip, ink, outline, … }

// browser: draw into an element and keep it drawn
const table = Dice.init('#hero', { seed: 'spintax.net' });
table.set({ result: 'snake' });
table.destroy();

Why it looks the way it looks

The brand's colours become the casino table: the first chromatic colour felts it, a gold-hue colour tones the brass trim; the dice keep near-black pips in every brand. The table's edge wears that same near-black — a dark surround, never a colour — and rail: 'brand' / rail: 'felt' / any colour pin reshapes it ('brand' brings back the brand-coloured pad). Under theme: 'light' the table defaults to a line drawing — a filled felt over a white page was a pastel field in every sibling that tried it. Pin felt and rail to 'transparent' and only the lattice is left, the page showing through — the showcase above. body: 'glass' frosts the dice: one tinted fill, outlined, the dice behind reading through the dice in front. The picture carries no fixed path data: every coordinate is computed from the seed, so same (seed, options) → identical bytes, always.

Install

npm install @spintax/dice-lite

ES5, one file, UMD tail — CommonJS, ESM default import and a plain <script> (global Dice) all work. dice.d.ts ships the types. Playground →

The family

dice-lite is a sibling of seven zero-dependency libraries by the same hands — slots-lite (its closest relative — a slot machine drawn whole, whose colour engine and seeding it shares), cards-lite, roulette-lite, trigons-lite, hexagons-lite, octagons and qr-svg.

Licence and credits

MIT. Made in 301 · for spintax.net.

About

A procedural throw of dice as an SVG string. Seeded placement and values, brand-aware table palette, paper or frosted-glass bodies, an optional CSS roll. Zero dependencies; runs in Node at build time and in the browser.

investblog.github.io/dice-lite/

Topics

casinocrapsdicediegamblinggenerativegenerative-arthero-backgroundillustrationline-artpaletteproceduralssrstatic-sitesvgvanilla-jszero-dependencies

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.