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);functionWhat it prints (run when this page was built)