リファレンス
カード・手札・山札
import { … } from "@johnmorrisdotca/toranpu/element";
最小化と gzip 圧縮をしたサイズは 242.8 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Toranpu's custom elements, for any page and any framework that renders HTML, and the arithmetic behind them:
<toranpu-card>: one card, in any design and with any back, turned over by a tap.<toranpu-hand>: a hand, fanned; turned face down where it lies, all at once or one by one; squared up into a bundle that shows nothing; or held closed, to open on a tap.<toranpu-pile>: a stock or a discard pile, neat or messy, from a seed.
import { defineToranpuElements } from "@johnmorrisdotca/toranpu/element";
defineToranpuElements();
document.body.insertAdjacentHTML("beforeend", '<toranpu-card card="KS" design="english" flip></toranpu-card>');Or with no call at all: importing @johnmorrisdotca/toranpu/element/define
registers them by being imported.
Your own faces and backs: registerCardDesign and registerCardBack (also from /card-faces and /card-backs) keep
them by name, so design="frontier" and back="frontier" work on every element of the page; a card also takes
an element in slot="face" or slot="back", or a face function.
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
arrangeCards | 関数 | A hand laid out another way, as a new list (the one given is left alone): "rank" sorts it low to high, the ace high, a rank's cards in suit order; "suit" groups it by suit, spades, hearts, clubs, diamonds, each in rank order; "face" groups it into the number cards, ace to ten, and then the face cards, jack, queen, king, each group in rank order and a rank's cards in suit order; "dealt" keeps the order given. |
BUNDLE_BACKS | 定数 | How many backs a squared-up bundle shows, whatever the hand: a bundle never tells how many cards are in it. |
CardFaceContext | 型 | What a card's face function is told: the language the card speaks, and the design it names. |
CardFaceRenderer | 型 | A function that draws a card's face: given the card's id and its context, SVG markup (drawn on the card's paper in a box 100 by 140, or a whole <svg> document), or an element, or null to draw the card as its design does. |
CardLands | 型 | Where a card a hand is given goes: to the front, or the end. |
CardOrder | 型 | How a hand's cards are laid out: as they were dealt, by rank, grouped by suit, or the number cards apart from the face cards. |
CardPlace | 型 | One card's place: across and down in card widths from where the first lies, and its turn in degrees. |
defineHand | 関数 | Register a hand under its standard tag or a host-supplied tag. |
defineToranpuElements | 関数 | Register the elements under their tags, once; a tag already taken is left as it is. |
ELEMENT_SIZES | 定数 | The sizes every element takes, as a card's width in pixels. |
handLayout | 関数 | Where each card of a hand of count lies: a fan when open, a squared-up stack with a sliver of each card showing when closed, and every shape in between. |
HandLayoutOptions | 型 | How a hand is laid out. |
HandTurnOptions | 型 | How a hand's cards are turned face down or face up. |
mixCards | 関数 | A hand mixed up, as a new list: the same cards in another order, never the order given (where a hand has two cards or more that differ), so a mix is always seen to change something. |
partedHandLayout | 関数 | A HAND PARTED AT ONE CARD: that card lifted a little, upright and wholly in view, and the cards to its left and right drawn apart from it into a group on each side (one group where it is the first or the last). |
PartOptions | 型 | How a parted hand is laid out. |
pileLayout | 関数 | Where each card of a pile of count lies, bottom first, the top card last: at 0 messiness a neat stack whose edge shows a card's thickness for each card under the top, and towards 1 a heap, each card nudged and turned a little more. |
PileLayoutOptions | 型 | How a pile is laid out. |
readHand | 関数 | A hand written as text, as its cards: the two-letter ids separated by spaces or commas ("AS KH 10D TC RJ", with 10 for ten as well as T), or the deck's one-letter codes run together ("pvOZ"). |
registerCardBack | 関数 | Keep a back by its name. |
registerCardDesign | 関数 | Keep a design by its name, in place of any earlier one of that name. |
replaceCard | 関数 | A hand with one card tossed out and another given in its stead, at the front or the end: as a new list. |
SpinOptions | 型 | How a card is spun. |
TORANPU_TAGS | 定数 | The elements' tags. |
ToranpuCard | クラス | ONE CARD ON ANY PAGE: <toranpu-card card="QS">, in any design and with any back, face up or face down, turned over by a tap when it has flip. |
ToranpuHand | クラス | A HAND OF CARDS ON ANY PAGE: <toranpu-hand cards="AS KH QD">, fanned, in any design and with any back. |
ToranpuPile | クラス | A PILE OF CARDS ON ANY PAGE: <toranpu-pile>, a stock to draw from or a discard pile, its top card on top and the cards under it showing as a stack, from neatly squared to very messy. |
tossCard | 関数 | A hand without one card, as a new list: the first of that card taken out, or the hand unchanged where it holds none. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。