Files

37 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# poker.js — drawCardComponent() (satır 99)
[← poker.js](index.md) · [← Master](../../wiki.md)
```javascript
function drawCardComponent(ui, cardStr, rxRatio, ryRatio, xOffset, yOffset) {
// Card base (width 28, height 38, centered)
var cardBg = ui.graphics().rx(rxRatio, xOffset).ry(ryRatio, yOffset).wh(28, 38).anchor(0.5);
// White card background
cardBg.rect(0, 0, 28, 38, 0xFFFDFDFD);
// Dark gray border
cardBg.rect(0, 0, 28, 1, 0xFF777777);
cardBg.rect(0, 37, 28, 1, 0xFF777777);
cardBg.rect(0, 0, 1, 38, 0xFF777777);
cardBg.rect(27, 0, 1, 38, 0xFF777777);
if (!cardStr) {
// Red/blue back pattern for face-down cards
cardBg.rect(2, 2, 24, 34, 0xFF990000);
cardBg.rect(4, 4, 20, 30, 0xFFD4AF37);
cardBg.rect(6, 6, 16, 26, 0xFF990000);
return;
}
var suit = cardStr.charAt(cardStr.length - 1);
var rank = cardStr.substring(0, cardStr.length - 1);
var isRed = (suit === "♥" || suit === "♦");
var colorCode = isRed ? "§c" : "§0";
// Rank text directly inside cardBg
cardBg.text(colorCode + rank, 2, 2, 0xFFFFFFFF);
// Suit text directly inside cardBg at bottom-right
cardBg.text(colorCode + suit, 14, 23, 12, 12, 0xFFFFFFFF, 0.5, 0.5);
}
```