Created
October 29, 2023 20:37
-
-
Save g-simmons/0121cb88ab46910670ebfae7c2a22931 to your computer and use it in GitHub Desktop.
Simple playing cards in typst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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