Skip to content

Instantly share code, notes, and snippets.

@g-simmons
Created October 29, 2023 20:37
Show Gist options
  • Save g-simmons/0121cb88ab46910670ebfae7c2a22931 to your computer and use it in GitHub Desktop.
Save g-simmons/0121cb88ab46910670ebfae7c2a22931 to your computer and use it in GitHub Desktop.
Simple playing cards in typst
#let card(cardname) = {
let (card, suit) = cardname.split(" of ")
let suits = (
"hearts": sym.suit.heart,
"diamonds": sym.suit.diamond,
"clubs": sym.suit.club,
"spades": sym.suit.spade,
)
let suit_colors = (
"hearts": "red",
"diamonds": "red",
"clubs": "black",
"spades": "black",
)
[
#box(stroke: 1pt, height: 3em, width: 2em)[
#set text(fill: eval(suit_colors.at(suit)))
#align(left + top, suits.at(suit))
#align(horizon + center, card)
#align(bottom + right, suits.at(suit))
]
]
}
#card("A of hearts")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment