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 · Card designs

cardFaceSvgfunction

A card's face as a whole SVG document, 100 by 140: QS, TD, a joker (RJ, BJ), a rules card (R1, R2) or the blank (BL). null for anything that is not a card. The plain design unless another is asked for; a design handed in that has no drawing for the card draws it plain.

Drawn into a page, the plain and four-colour faces take their colours from --toranpu-card, --toranpu-card-ink, --toranpu-card-red, --toranpu-card-blue and --toranpu-card-green where they are set; as an image they keep their own.

Import it

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

Definition

function cardFaceSvg(card: string, options?: CardFaceOptions): string | null

Parameters

NameTypeDescription
cardstring

The physical card or card id to read, draw or play.

options (optional)CardFaceOptions

Options for this call; omitted fields retain their documented defaults.

Returns

string | null

A card's face as a whole SVG document, 100 by 140: QS, TD, a joker (RJ, BJ), a rules card (R1, R2) or the blank (BL). null for anything that is not a card. The plain design unless another is asked for; a design handed in that has no drawing for the card draws it plain. Drawn into a page, the plain and four-colour faces take their colours from --toranpu-card, --toranpu-card-ink, --toranpu-card-red, --toranpu-card-blue and --toranpu-card-green where they are set; as an image they keep their own.

Examples

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

console.log(cardFaceSvg("AS", { width: 80 })?.slice(0, 160));
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 140" width="80" height="112" role="img" aria-label="ace of spades" style="user-select:none;-webkit-user

What it prints (run when this page was built)

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