nanDECK - Tutorial E
This tutorial was written for nanDECK 1.9c (or later versions).
For a standard poker deck, we need four symbols (hearts, diamonds, clubs and spades). You can find them in Symbol font, at these ASCII codes:
169 = Hearts
168 = Diamonds
170 = Spades
167 = Clubs
We can define some positions' labels, one for the suite'
symbol and one for the values:
[pos_sym]=0,1.5,1.5,1.5
[pos_val]=0,0,1.5,1.5
Four labels for the four corners of a card:
[pos_tl]=0,0,1.5,3
[pos_bl]=0,6,1.5,3
[pos_tr]=4.5,0,1.5,3
[pos_br]=4.5,6,1.5,3
Two labels for the fonts (Symbol and Arial):
[char_sym]=symbol,36,"B"
[char_val]=arial,36,"B"
Two labels for the colors:
[red]=#FF0000
[black]=#000000
And a sequence for all the values:
[val]="A|2|3|4|5|6|7|8|9|10|J|Q|K"
Let's go, we set the font and write the value for red cards:
font=[char_val],[red]
text="1-26",[val],[pos_val],"center"
Note the range 1-26, for 13 hearts and 13 diamonds, the sequence
is long 13 but it repeats at the end. Then we change font and write the symbols,
hearts and diamonds:
font=[char_sym],[red]
text="1-13","\169\",[pos_sym],"center"
text="14-26","\168\",[pos_sym],"center"
Remember, the syntax for an ASCII code is \number\. This is the similar code for black cards:
font=[char_val],[black]
text="27-52",[val],[pos_val],"center"
font=[char_sym],[black]
text="27-39","\167\",[pos_sym],"center"
text="40-52","\170\",[pos_sym],"center"
This is the result (only showing the aces):
This is the top left corner (pos_tl), for the others three corners (pos_tr, pos_bl and pos_br), we can copy this section with a COPY command, rotating the bottom two corners of 180°:
copy="1-52",[pos_tl],[pos_tr],0
copy="1-52",[pos_tl],[pos_bl],180
copy="1-52",[pos_tl],[pos_br],180
This is the result:
Now, you can write every pip with a single command, but starting with version 1.9c there are a couple of features in nanDECK's really useful. First, in TEXT command there is a vertical alignment parameter for wordwrapping single characters in pattern (charwrap), second, you can repeat strings with {X number} syntax. So we define a center area:
[pos_cnt]=1,1,4,7
And write pips for hearts:
font=[char_sym],[red]
text=1-10,"\169\{X§}",[pos_cnt],"center","charwrap"
Remember, the § symbol is used for the current card's number, 1 for the first card (the ace), 2 for the second, and so on. The result is this (first five cards):
This is the code for the Diamonds suite, the range is starting from the ace (and ten cards forward):
text=14-23,"\168\{X§-13}",[pos_cnt],"center","charwrap"
Note the {§-13} syntax for obtaining again a 1-10 range values. This is the code for black cards:
font=[char_sym],[black]
text=27-36,"\167\{X§-26}",[pos_cnt],"center","charwrap"
text=40-49,"\170\{X§-39}",[pos_cnt],"center","charwrap"
Finally, we use three images for Jacks, Queens and Kings, with this code (you can use other images):
image="11,24,37,50","jack.gif",[pos_cnt],0,TP
image="12,25,38,51","queen.gif",[pos_cnt],0,TP
image="13,26,39,52","king.gif",[pos_cnt],0,TP
Note the "T" flag for transparency and "P" flag to keep image's proportions. These are three cards from Hearts suite:
You can download this script from here and the PDF from here.
Bye,
/\/and