本文へ移動

Kyuubuキューブ

CSS 3Dのキューブをタッチ、キー、回転記号で回します。シードでスクランブルを再現し、名前付きの手順で解き方を追えます。

「キューブ」は、英語のcubeを表す日本語の表記です。 名前について(英語)

目次

リファレンス · キューブのエンジンと表示

CubeViewOptions型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Everything a cube on the screen can be told when it is made. Only size is needed.

インポート

import type { CubeViewOptions } from "@johnmorrisdotca/kyuubu";

定義

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;
};

メンバー

名前型説明
sizenumber

The cube's side: 2 for a 2×2, 3 for the classic.

state (省略可)string | undefined

The stickers, one letter each (solvedCube); solved when left out.

colours (省略可)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 (--kyuubu-up and the rest), and the standard colour where that is not set.

plastic (省略可)string | undefined

The colour of the plastic between stickers and inside the cube. Left out, it is --kyuubu-plastic, and #111 where that is not set.

theme (省略可)CubeTheme | undefined

A whole look at once: colours, plastic and the shape of a sticker. colours and plastic given beside it win.

rounded (省略可)boolean | undefined

Whether the cube's corners are rounded, like the plastic of a real one: true when left out. The theme's cornerRadius says how round.

locale (省略可)KyuubuLanguage | undefined

The language of the cube's accessible name: English or Japanese. Left out, it follows the page's lang.

scale (省略可)"small" | "medium" | "large" | undefined

How big it is drawn: small (72 pixels, for a list or a picker), medium (160) or large (300). The host is given that width and kept square. Left out, the cube fills the box it is in. width wins over it. A small cube is look-only unless interactive says otherwise.

width (省略可)number | undefined

How wide it is drawn, in pixels, in place of scale's.

interactive (省略可)boolean | undefined

Whether a person can turn it. A look-only cube still turns when asked (turn). True when left out, except at small.

keyboard (省略可)"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 (省略可)boolean | undefined

Whether scramble shows the turns it makes: the last few, quickly, after the rest are made at once. True when left out; a device that asks for reduced motion shows none whatever this says.

turnMs (省略可)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. setTurnMs changes it later.

commitAngle (省略可)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 (省略可)number | undefined

How the cube is first seen: turned about its up axis, in degrees.

pitch (省略可)number | undefined

How the cube is first seen: tipped towards the viewer, in degrees.

fill (省略可)number | undefined

How much of the space the cube fills, 0 to 1.

onTurn (省略可)((move: CubeMove, state: string) => void) | undefined

A turn a person made, with the cube's stickers once it is done.

onLook (省略可)((yaw: number, pitch: number) => void) | undefined

Every time the view is turned, for anything that wants to keep it.

label (省略可)string | undefined

What a screen reader calls the cube. Left out, it is "A 3×3 cube" in the cube's language.

例

import type { CubeViewOptions } from "@johnmorrisdotca/kyuubu";


const value: CubeViewOptions = { size: 3, interactive: true, keyboard: "focus" };
console.log(value.size);
3

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/kyuubu 1.14.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。