CardDesign型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
A set of drawn cards: its name, the box each card is drawn in, and each
card's drawing (what goes inside an <svg> of that box) by its id, KS for
the king of spades and RJ and BJ for the red and black jokers. A card
the set has no drawing for is drawn plain.
A set may also be a page's own: faces for the standard cards in its own art,
or cards no deck has, such as a territory card or a card a game invents. Give
such a card any id of letters, digits, -, _, . or : (up to 40), and
either its drawing in art or a function that draws it in draw. See
registerCardDesign.
インポート
import type { CardDesign } from "@johnmorrisdotca/toranpu/card-faces";
定義
type CardDesign = {
name: string;
box: readonly [
number,
number
];
art: Readonly<Record<string, string>>;
fallback?: CardDesign;
draw?: (card: string, context: {
language: "en" | "ja";
}) => string | null;
label?: (card: string, language: "en" | "ja") => string | null | undefined;
frame?: "paper" | "none";
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
name | string | The design's name, as |
box | readonly [number, number] | The width and height each card is drawn in. |
art | Readonly<Record<string, string>> | Each card's drawing, by its id. |
fallback (省略可) | CardDesign | undefined | Where the set has no drawing for a card, the set that draws it instead; then plain. |
draw (省略可) | ((card: string, context: { language: "en" | "ja"; }) => string | null) | undefined | Cards drawn by a function rather than from |
label (省略可) | ((card: string, language: "en" | "ja") => string | null | undefined) | undefined | What a screen reader says for a card of the set, in the language asked for; null or nothing for a card the set leaves to its usual name (a standard card), or to its id (any other). |
frame (省略可) | "paper" | "none" | undefined | How the card is framed. |
例
import type { CardDesign } from "@johnmorrisdotca/toranpu/card-faces";
const value: CardDesign = { name: "docs-face", box: [100, 140], art: { "docs-card": `<circle cx="50" cy="70" r="20"/>` } };
console.log(value.name);docs-face出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。