Reference · Cube engine and views
CubeViewOptionstype
Everything a cube on the screen can be told when it is made. Only size is needed.
Import it
import type { CubeViewOptions } from "@johnmorrisdotca/kyuubu";
Definition
type CubeViewOptions = {
size: number;
state?: string;
colours?: Partial<Record<CubeFace, string>>;
plastic?: string;
theme?: CubeTheme;
rounded?: boolean;
locale?: KyuubuLanguage;
scale?: CubeScale;
width?: number;
interactive?: boolean;
keyboard?: "focus" | "page" | "none";
animateScramble?: boolean;
turnMs?: number;
commitAngle?: number;
yaw?: number;
pitch?: number;
fill?: number;
onTurn?: (move: CubeMove, state: string) => void;
onLook?: (yaw: number, pitch: number) => void;
label?: string;
};
Members
| Name | Type | Description |
|---|---|---|
size | number | The cube's side: 2 for a 2×2, 3 for the classic. |
state (optional) | string | undefined | The stickers, one letter each ( |
colours (optional) | Partial<Record<"U" | "R" | "F" | "D" | "L" | "B", string>> | undefined | Colours for the six faces, by the letter a solved face carries. A face left out takes its CSS custom property ( |
plastic (optional) | string | undefined | The colour of the plastic between stickers and inside the cube. Left out, it is |
theme (optional) | CubeTheme | undefined | A whole look at once: colours, plastic and the shape of a sticker. |
rounded (optional) | boolean | undefined | Whether the cube's corners are rounded, like the plastic of a real one: true when left out. The theme's |
locale (optional) | KyuubuLanguage | undefined | The language of the cube's accessible name: English or Japanese. Left out, it follows the page's |
scale (optional) | "small" | "medium" | "large" | undefined | How big it is drawn: |
width (optional) | number | undefined | How wide it is drawn, in pixels, in place of |
interactive (optional) | boolean | undefined | Whether a person can turn it. A look-only cube still turns when asked ( |
keyboard (optional) | "focus" | "page" | "none" | undefined | Where the keys are listened for: the cube itself once it has focus (the default), the whole page, or nowhere. |
animateScramble (optional) | boolean | undefined | Whether |
turnMs (optional) | number | undefined | How long a quarter turn takes, in milliseconds, when it is made by a key, by notation or from code: 160 when left out. A device that asks for reduced motion gets no animation, whatever this says. |
commitAngle (optional) | number | undefined | The point of no return of a dragged layer, in degrees: 30 when left out. A layer let go short of it goes back and no move is made; at it or past it, the turn is completed. From 5 to 85. |
yaw (optional) | number | undefined | How the cube is first seen: turned about its up axis, in degrees. |
pitch (optional) | number | undefined | How the cube is first seen: tipped towards the viewer, in degrees. |
fill (optional) | number | undefined | How much of the space the cube fills, 0 to 1. |
onTurn (optional) | ((move: CubeMove, state: string) => void) | undefined | A turn a person made, with the cube's stickers once it is done. |
onLook (optional) | ((yaw: number, pitch: number) => void) | undefined | Every time the view is turned, for anything that wants to keep it. |
label (optional) | string | undefined | What a screen reader calls the cube. Left out, it is "A 3×3 cube" in the cube's language. |
Examples
import type { CubeViewOptions } from "@johnmorrisdotca/kyuubu";
const value: CubeViewOptions = { size: 3, interactive: true, keyboard: "focus" };
console.log(value.size);3What it prints (run when this page was built)