CuboidPlayerHandletype
A cuboid player on the page.
Import it
import type { CuboidPlayerHandle } from "@johnmorrisdotca/kyuubu/cuboid/play";
Definition
type CuboidPlayerHandle = {
readonly plan: CuboidReplayPlan | null;
readonly fault: CuboidReplayFault | null;
load(source: CuboidReplaySource, how?: {
speed?: number;
loop?: boolean;
controls?: boolean;
autoplay?: boolean;
}): void;
play(): void;
pause(): void;
step(by: 1 | -1): void;
seek(position: number): void;
restart(): void;
setSpeed(speed: number): void;
setLoop(loop: boolean): void;
setLocale(locale: KyuubuLanguage): void;
setTheme(theme: CubeTheme): void;
setAnimateScrub(on: boolean): void;
readonly animatingScrub: boolean;
readonly status: ReplayStatus | null;
readonly view: CuboidView;
destroy(): void;
};
Members
| Name | Type | Description |
|---|---|---|
plan | CuboidReplayPlan | null | The solve as it was read, or why it could not be. |
fault | CuboidReplayFault | null | |
load | (source: CuboidReplaySource, how?: { speed?: number; loop?: boolean; controls?: boolean; autoplay?: boolean; }): void | Another solve on the same puzzle, in place of the one showing. The speed and the repeat are kept unless given. |
play | (): void | |
pause | (): void | |
step | (by: 1 | -1): void | One step on (1) or back (-1). |
seek | (position: number): void | To the puzzle after this many steps. |
restart | (): void | |
setSpeed | (speed: number): void | |
setLoop | (loop: boolean): void | |
setLocale | (locale: KyuubuLanguage): void | |
setTheme | (theme: CubeTheme): void | |
setAnimateScrub | (on: boolean): void | Whether moving the slider turns the puzzle between where it was and where it goes. |
animatingScrub | boolean | Whether it does. |
status | ReplayStatus | null | |
view | CuboidView | The puzzle as drawn, for a page that wants to look at it. |
destroy | (): void | Take it off the page, with every listener. |
Examples
import type { CuboidPlayerHandle } from "@johnmorrisdotca/kyuubu/cuboid/play";
import { mountCuboidPlayer } from "@johnmorrisdotca/kyuubu/cuboid/play";
const value: CuboidPlayerHandle = mountCuboidPlayer(document.createElement("div"), { dims: [2, 3, 3], scramble: "R", solution: "R'", autoplay: false });
console.log(value.plan?.solved);