リファレンス
カードの裏面
import { … } from "@johnmorrisdotca/toranpu/card-backs";
最小化と gzip 圧縮をしたサイズは 3.5 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The backs of the cards, drawn as SVG: one home for every card game in the family. Three to start: a classic red and a classic blue in the manner of a casino back, and ink with dots. Each can be recoloured, carry a site's mark in its middle, and comes as an SVG document or a data URL.
import { cardBackSvg, cardBackUrl } from "@johnmorrisdotca/toranpu/card-backs";
element.innerHTML = cardBackSvg("classic-blue", { width: 70 });
image.src = cardBackUrl("ink-dots", { colour: "#8f2826", mark: "五つ" });Your own back: SVG art, a picture or colours, and a logo in the middle, drawn by cardBackSvg or registered under a name
that back="…" on any card, hand, pile or table then takes.
import { registerCardBack, cardBackSvg } from "@johnmorrisdotca/toranpu/card-backs";
registerCardBack("frontier", { colour: "#2f4a3a", ink: "#e7d9a8", logo: `<circle cx='50' cy='50' r='40'/>` });
element.innerHTML = cardBackSvg("frontier", { width: 70 });エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
CARD_BACK_LOOK | 定数 | Each back's own colours: its field, the lines and dots drawn on the field, and the paper round it. |
CARD_BACK_PROPERTIES | 定数 | The CSS custom properties a back drawn into a page takes its colours from, when no colour is given. |
CARD_BACKS | 定数 | The backs, by name. |
CARD_BOX | 定数 | A card is drawn in a box 100 wide and 140 tall, the 5:7 of a poker-size card, and scales to any width. |
CardBackName | 型 | One back's name. |
cardBackNames | 関数 | The backs a page may ask for by name: the package's own, and any the page registered (registerCardBack). |
CardBackOptions | 型 | How a back is drawn. |
cardBackSvg | 関数 | A back as a whole SVG document, 100 by 140. |
cardBackUrl | 関数 | A back as a data URL, for an <img src>, a CSS background or a canvas: the same drawing as cardBackSvg, with its own colours. |
CardSuitLetter | 型 | A suit as one letter, as a card's id writes it: spades, hearts, diamonds, clubs. |
registerCardBack | 関数 | Keep a back by its name. |
RegisteredCardBack | 型 | A back registered by name: how it is drawn, and the built-in back it starts from. |
registeredCardBacks | 関数 | The names of the backs registered now, in the order they were. |
SUIT_PATHS | 定数 | The four suits, each a path in a box of 100 filled in one colour. |
unregisterCardBack | 関数 | Forget a registered back. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。