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

pileLayoutfunction

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. Seeded, so the same pile always looks the same, and adding a card on top moves none of those under it. Only the top depth cards under the top one are given places; a pile is never drawn deeper than that.

Import it

import { pileLayout } from "@johnmorrisdotca/toranpu/element";

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

Definition

function pileLayout(count: number, options?: PileLayoutOptions): CardPlace[]

Parameters

NameTypeDescription
countnumber

The requested number of cards, sounds or layout positions.

options (optional)PileLayoutOptions

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

Returns

CardPlace[]

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. Seeded, so the same pile always looks the same, and adding a card on top moves none of those under it. Only the top depth cards under the top one are given places; a pile is never drawn deeper than that.

Examples

import { pileLayout } from "@johnmorrisdotca/toranpu/element";

console.log(pileLayout(3, { seed: 42, messiness: 0.5 }));
[
  { x: 0.001, y: 0.02, rotate: 5.071 },
  { x: 0.029, y: -0.004, rotate: -1.936 },
  { x: 0.026, y: -0.006, rotate: 3.17 }
]

What it prints (run when this page was built)

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