/** * THE FACES OF THE CARDS, drawn as SVG in the same 100 by 140 box as the * backs. Plain is the default: big corners, the pips laid out as a real deck * lays them, and kings, queens and jacks as their letter in a frame. Four * colour is the same with diamonds blue and clubs green, as poker players * like them. The English pattern, the traditional deck with drawn kings, * queens and jacks, is its own entry point because of its size (see * `designs/english.ts`), and is handed in as a design. */ import { type Language } from "../strings.ts"; import type { CardDesign } from "./card-faces.types.ts"; /** The designs drawn here, by name. The English pattern is `ENGLISH_PATTERN` from `@johnmorrisdotca/toranpu/card-faces/english`, or `loadCardDesign("english")`. * * @example * ```ts * import { CARD_DESIGNS } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(CARD_DESIGNS); * ``` */ export declare const CARD_DESIGNS: readonly ["plain", "four-colour", "english", "realistic"]; /** A design's name. * * @example * ```ts * import type { CardDesignName } from "@johnmorrisdotca/toranpu/card-faces"; * * const value: CardDesignName = "english"; * console.log(value); * ``` */ export type CardDesignName = (typeof CARD_DESIGNS)[number]; /** The two jokers' ids: the red joker and the black. No game here plays with them; a table of your own may. * * @example * ```ts * import { JOKERS } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(JOKERS); * ``` */ export declare const JOKERS: readonly ["RJ", "BJ"]; /** How a face is drawn. Every field may be left out. * * @example * ```ts * import type { CardFaceOptions } from "@johnmorrisdotca/toranpu/card-faces"; * * const value: CardFaceOptions = { design: "four-colour", width: 80, language: "ja" }; * console.log(value.design); * ``` */ export type CardFaceOptions = { /** `"plain"` (unless said), `"four-colour"`, a design handed in, such as `ENGLISH_PATTERN`, or the name of a design the page has registered (`registerCardDesign`). */ design?: "plain" | "four-colour" | CardDesign | (string & {}); /** The width to draw at, in pixels; the height is 1.4 times it. Unless said, the drawing fills what holds it. */ width?: number; /** What a screen reader says. Unless said, the card's name in `language`, "queen of spades". An empty string makes it decoration. */ title?: string; /** The language of the card's name, and of a joker's corner word: `"en"` (unless said) or `"ja"`. */ language?: Language; }; /** The CSS custom properties a plain or four-colour face drawn into a page takes its colours from. * * @example * ```ts * import { CARD_FACE_PROPERTIES } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(CARD_FACE_PROPERTIES); * ``` */ export declare const CARD_FACE_PROPERTIES: { readonly paper: "--toranpu-card"; readonly black: "--toranpu-card-ink"; readonly red: "--toranpu-card-red"; readonly blue: "--toranpu-card-blue"; readonly green: "--toranpu-card-green"; }; /** The faces' own colours. * * @example * ```ts * import { CARD_FACE_COLOURS } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(CARD_FACE_COLOURS); * ``` */ export declare const CARD_FACE_COLOURS: { readonly paper: "#fffdf8"; readonly black: "#1b1b1b"; readonly red: "#c2272d"; readonly blue: "#1f5fbf"; readonly green: "#1f7a3a"; readonly edge: "#000"; }; /** * THE EXTRAS OF A REAL DECK, which no game here deals but a hand on a page may hold, as a wild * card or for the look of it: the two jokers, the two rules cards a pack is sold with (`R1`, * the rules of Hearts; `R2`, of Spades), and a blank (`BL`). A hand holds at most * `EXTRA_LIMITS` of each kind (`readHand`). * * @example * ```ts * import { EXTRA_CARDS } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(EXTRA_CARDS); * ``` */ export declare const EXTRA_CARDS: readonly ["RJ", "BJ", "R1", "R2", "BL"]; /** The most of each kind of extra one hand holds: four jokers, as some packs have; two rules cards; two blanks. * * @example * ```ts * import { EXTRA_LIMITS } from "@johnmorrisdotca/toranpu/card-faces"; * console.log(EXTRA_LIMITS); * ``` */ export declare const EXTRA_LIMITS: { readonly jokers: 4; readonly rules: 2; readonly blanks: 2; }; /** Whether a text is a card a face can be drawn for: `QS`, `TD`, a joker (`RJ`, `BJ`), a rules card (`R1`, `R2`) or the blank (`BL`). * * @param text - The notation, encoded state or saved text to read. * @returns Whether a text is a card a face can be drawn for: `QS`, `TD`, a joker (`RJ`, `BJ`), a rules card (`R1`, `R2`) or the blank (`BL`). * * @example * ```ts * import { isCardFace } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(isCardFace("AS")); * ``` */ export declare function isCardFace(text: unknown): text is string; /** The middles of a number card's pips, in the 100 by 140 box, and whether each is drawn upside down. * * @param count - The requested number of cards, sounds or layout positions. * @returns The middles of a number card's pips, in the 100 by 140 box, and whether each is drawn upside down. * * @example * ```ts * import { pipPlaces } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(pipPlaces(7)); * ``` */ export declare function pipPlaces(count: number): { x: number; y: number; down: boolean; }[]; /** The design an option names: a design handed in as it is, a registered one by its name, and the two drawn here as their names. */ export declare function designOf(design: CardFaceOptions["design"]): "plain" | "four-colour" | CardDesign; /** * 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. * * @param card - The physical card or card id to read, draw or play. * @param options - Options for this call; omitted fields retain their documented defaults. * @returns 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. * * @example * ```ts * import { cardFaceSvg } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(cardFaceSvg("AS", { width: 80 })?.slice(0, 160)); * ``` */ export declare function cardFaceSvg(card: string, options?: CardFaceOptions): string | null; /** * A card's face from artwork of your own: `art` is SVG markup (or a whole `` document) drawn on the card's paper in * a box 100 by 140, or in `box`, fitted to the card's height and centred; a whole `` is used as it is. It is how a * page draws a card no deck has, for one card, with no design registered. `frame: "none"` leaves the paper out for art that * fills the card. Scripts, handlers and foreign objects are taken out of the markup. * * @param art - SVG markup for the face artwork. * @param options - Options for this call; omitted fields retain their documented defaults. * @returns A card's face from artwork of your own: `art` is SVG markup (or a whole `` document) drawn on the card's paper in a box 100 by 140, or in `box`, fitted to the card's height and centred; a whole `` is used as it is. It is how a page draws a card no deck has, for one card, with no design registered. `frame: "none"` leaves the paper out for art that fills the card. Scripts, handlers and foreign objects are taken out of the markup. * * @example * ```ts * import { cardFaceFromArt } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(cardFaceFromArt(``).slice(0, 160)); * ``` */ export declare function cardFaceFromArt(art: string, options?: Omit & { box?: readonly [number, number]; frame?: "paper" | "none"; }): string; /** A card's face as a data URL, for an , a CSS background or a canvas. `null` for anything that is not a card. * * @param card - The physical card or card id to read, draw or play. * @param options - Options for this call; omitted fields retain their documented defaults. * @returns A card's face as a data URL, for an , a CSS background or a canvas. `null` for anything that is not a card. * * @example * ```ts * import { cardFaceUrl } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(cardFaceUrl("KH")?.slice(0, 40)); * ``` */ export declare function cardFaceUrl(card: string, options?: CardFaceOptions): string | null; /** * A face's name in words: "queen of spades", "red joker"; in Japanese "スペードのクイーン", "赤のジョーカー". A card * of a design of the page's own, given as `design`, is named by that design's `label`, or by its id. * * @param card - The physical card or card id to read, draw or play. * @param language - English or Japanese for the displayed words. * @param design - The card-face design or registered design name. * @returns A face's name in words: "queen of spades", "red joker"; in Japanese "スペードのクイーン", "赤のジョーカー". A card of a design of the page's own, given as `design`, is named by that design's `label`, or by its id. * * @example * ```ts * import { faceName } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log(faceName("AS", "en")); * ``` */ export declare function faceName(card: string, language?: Language, design?: CardDesign): string; /** * A design by its name, loaded when it is first asked for: `"english"` fetches * the English pattern (about 700 kB, 200 kB compressed) only then. `"plain"` * and `"four-colour"` are drawn here and need no loading; they give `null`. A * design the page registered under the name is given as it is. * * @param name - The registered card design or card-back name. * @returns A design by its name, loaded when it is first asked for: `"english"` fetches the English pattern (about 700 kB, 200 kB compressed) only then. `"plain"` and `"four-colour"` are drawn here and need no loading; they give `null`. A design the page registered under the name is given as it is. * * @example * ```ts * import { loadCardDesign } from "@johnmorrisdotca/toranpu/card-faces"; * * console.log((await loadCardDesign("english"))?.name); * ``` */ export declare function loadCardDesign(name: CardDesignName | string): Promise;