Skip to the content

Toranpuトランプ

Use a deck, play eleven games with computers, solve a solitaire, or display cards in your own design.

Toranpu is Japanese for playing cards. About the name

Contents

Reference · Cards, hands and piles

CardFaceRenderertype

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.

Import it

import type { CardFaceRenderer } from "@johnmorrisdotca/toranpu/element";

Also exported from: @johnmorrisdotca/toranpu/element/define

Definition

type CardFaceRenderer = (card: string, context: CardFaceContext) => string | Node | null;

Examples

import type { CardFaceRenderer } from "@johnmorrisdotca/toranpu/element";
import { cardFaceSvg } from "@johnmorrisdotca/toranpu/card-faces";

const card = { suit: "spades", rank: 1 } as const;
const value: CardFaceRenderer = (card) => cardFaceSvg(card);
console.log(typeof value);
function

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/toranpu 2.15.0.