Skip to the content

Korokoroコロコロ

Roll mixed dice or type notation, compare exact probabilities, keep a history and replay seeded rolls.

Korokoro describes something small rolling in Japanese. About the name

Contents

Reference · Rolls and exact odds

DieOptionstype

What a lone die is told when it is made. Everything may be left out.

Import it

import type { DieOptions } from "@johnmorrisdotca/korokoro";

Definition

type DieOptions = {
    sides?: Sides;
    faces?: CustomFace[];
    face?: number;
    rollable?: boolean;
    size?: DieSize;
    width?: number;
    onePip?: "red" | "black";
    cloth?: Cloth;
    theme?: Record<`--kk-${string}`, string>;
    locale?: string;
    strings?: Partial<RollerStrings>;
    source?: RandomSource;
    animationMs?: number;
    sound?: boolean;
    playSound?: PlaySound;
    onRoll?: (face: number) => void;
};

Members

NameTypeDescription
sides (optional)Sides | undefined

The kind of die: 2 to 1000 sides, or "F" for a Fate die. 6 when left out.

faces (optional)CustomFace[] | undefined

A die of your own: its faces, in order, in place of numbers. sides is then their count.

face (optional)number | undefined

The face showing at first, from 1 (from −1 for a Fate die). Left out, the highest face of the die, or a 6 on a d6.

rollable (optional)boolean | undefined

Whether a tap rolls it: true when left out. False is a die that only shows a face.

size (optional)DieSize | undefined

small, medium (unless said) or large. width wins.

width (optional)number | undefined

Its width in pixels, in place of size.

onePip (optional)"red" | "black" | undefined

The colour of a d6's one pip: "red" (unless said) or "black".

cloth (optional)"green" | "blue" | "red" | "black" | "wood" | undefined

A cloth's name, for the page's own colours to follow the tray's: only the ink and the die's edge on a felt. theme is laid over it.

theme (optional)Record<`--kk-${string}`, string> | undefined

CSS variables for the die, such as { "--kk-die": "#fff" }.

locale (optional)string | undefined

"ja…" for Japanese, anything else English. The page's own language when left out.

strings (optional)Partial<RollerStrings> | undefined

Words to use instead of the built-in ones.

source (optional)RandomSource | undefined

Where the throw comes from: seededSource("table") makes the same throws for everyone. Cryptographic when left out.

animationMs (optional)number | undefined

The length of the tumble in milliseconds: 600 when left out. Reduced motion always skips it.

sound (optional)boolean | undefined

Whether a throw makes the sound of dice. Off when left out, because a die on its own is a thing on somebody's page, and a page that has not asked for noise gets none.

playSound (optional)PlaySound | undefined

A sound of your own for each throw, in place of the recorded dice. Used only when sound is true.

onRoll (optional)((face: number) => void) | undefined

Called once the die has landed, with the face.

Examples

import type { DieOptions } from "@johnmorrisdotca/korokoro";
const value: DieOptions = { sides: 20, face: 6, sound: false };
console.log(value.sides);
20

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/korokoro 1.16.0.