本文へ移動

Toranpuトランプ

デッキを使い、11種類のゲームでコンピューターと対戦し、ソリティアを解いたり、独自の絵柄でカードを表示したりできます。

「トランプ」は、日本語で playing cards を指す言葉です。 名前について(英語)

目次

リファレンス

カードの裏面

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.

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

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