function draw_playing_card ($suit, $value, $face_down, $size, $x, $y
{
//based in part on http://www.brainjar.com/css/cards/
switch ($suit) {
case 'diamonds'
$color = 'red'
$symbol = '♦'
break
case 'hearts'
$color = 'red'
$symbol = '♥'
break
case 'clubs'
$color = 'black'
$symbol = '♣'
break
case 'spades'
$color = 'black'
$symbol = '♠'
break
default
return ''
}
if ($face_down) {
$bgcolor = "brown"
} else {
$bgcolor = "#fffff2"
}
// card container
$card = "<div style=""
"border:1px solid black;"
"background-color:$bgcolor;"
"position:absolute;"
"font-size:{$size}px;"
"font-family:Arial,sans-serif;"
"width:3.7em;"
"height:5em;"
"border-radius:.2em;"
"-moz-border-radius:.2em;"
"-webkit-border-radius:.2em;"
"color:$color;"
"left:{$x}px;"
"top:{$y}px;"
"">"
if (!$face_down) {
// number & symbol in top corner
$card .= "<div style=""
"position:absolute;"
"font-size:50%;"
"font-weight:bold;"
"text-align:center;"
"left:0.25em;"
"top:0.25em;"
"">$value<br />$symbol</div>"
// non-face card
if (($value>=2) && ($value<=10)) {
/****** column 1 symbols *****/
if (($value>=4) && ($value<=10)) {
$card .= "<div style="". //row 1
"position:absolute;"
"left:0.6em;"
"top:0.5em;"
"">$symbol</div>"
$card .= "<div style="". //row 5
"position:absolute;"
"left:0.6em;"
"top:3.5em;"
"">$symbol</div>"
}
if (($value==9) || ($value==10)) {
$card .= "<div style="". //row 2
"position:absolute;"
"left:0.6em;"
"top:1.5em;"
"">$symbol</div>"
$card .= "<div style="". //row 4
"position:absolute;"
"left:0.6em;"
"top:2.5em;"
"">$symbol</div>"
}
if (($value==6) || ($value==7) || ($value==8)) {
$card .= "<div style="". //row 3
"position:absolute;"
"left:0.6em;"
"top:2em;"
"">$symbol</div>"
}
/****** column 2 symbols *****/
if (($value==2) || ($value==3)) {
$card .= "<div style="". //row 1
"position:absolute;"
"left:1.55em;"
"top:0.5em;"
"">$symbol</div>"
$card .= "<div style="". //row 5
"position:absolute;"
"left:1.55em;"
"top:3.5em;"
"">$symbol</div>"
}
if (($value==7) || ($value==8) || ($value==10)) {
$card .= "<div style="". //row 2
"position:absolute;"
"left:1.55em;"
"top:1em;"
"">$symbol</div>"
if ($value!=7) {
$card .= "<div style="". //row 4
"position:absolute;"
"left:1.55em;"
"top:3em;"
"">$symbol</div>"
}
}
if (($value==3) || ($value==5) || ($value==9)) {
$card .= "<div style="". //row 3
"position:absolute;"
"left:1.55em;"
"top:2em;"
"">$symbol</div>"
}
/****** column 3 symbols *****/
if (($value>=4) && ($value<=10)) {
$card .= "<div style="". //row 1
"position:absolute;"
"left:2.5em;"
"top:0.5em;"
"">$symbol</div>"
$card .= "<div style="". //row 5
"position:absolute;"
"left:2.5em;"
"top:3.5em;"
"">$symbol</div>"
}
if (($value==9) || ($value==10)) {
$card .= "<div style="". //row 2
"position:absolute;"
"left:2.5em;"
"top:1.5em;"
"">$symbol</div>"
$card .= "<div style="". //row 4
"position:absolute;"
"left:2.5em;"
"top:2.5em;"
"">$symbol</div>"
}
if (($value==6) || ($value==7) || ($value==8)) {
$card .= "<div style="". //row 3
"position:absolute;"
"left:2.5em;"
"top:2em;"
"">$symbol</div>"
}
}
// ace
else if ($value=='A') {
$card .= "<div style=""
"font-size:300%;"
"position:absolute;"
"text-align:center;"
"width:100%;"
"top:0.25em;"
"">$symbol</div>"
}
// jack, king, queen
else if (($value=='J')|| ($value=='Q')|| ($value=='K')) {
if ($value=='J') $sym'♞'
else if ($value=='Q') $sym'♛'
else if ($value=='K') $sym'♚'
$card .= "<div style=""
"border:1px solid black;"
"position:absolute;"
"left:0.6em;"
"top:0.55em;"
"width:2.45em;"
"height:3.85em;"
"">"
$card .= "<div style=""
"font-size:300%;"
"position:absolute;"
"text-align:center;"
"width:100%;"
"">$sym</div>"
$card .= "<div style=""
"position:absolute;"
"left:0.05em;"
"top:0em;"
"">$symbol</div>"
$card .= "<div style=""
"position:absolute;"
"right:0.05em;"
"bottom:0em;"
"">$symbol</div>"
$card .= "</div>"
}
}
$card .= "</div>"
return $card
}