Files

49 lines
1.7 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.
# satranc.js — tahtaCiz() (satır 282)
[← satranc.js](index.md) · [← Master](../../wiki.md)
```javascript
function tahtaCiz(uiContext, tahta, secili, hamleler, sahRenk)
{
var gfx = uiContext.get("board");
gfx.removeAll();
gfx.rect(0, 0, CW, CH, BG);
var ox = 10, oy = 10;
for (var r = 0; r < 8; r++)
{
for (var c = 0; c < 8; c++)
{
var x = ox + c * CELL;
var y = oy + r * CELL;
var i = idx(r, c);
var kareRenk = (r + c) % 2 === 0 ? KARE_A : KARE_B;
if (i === secili) kareRenk = SECILI;
var hamleVar = false;
for (var h = 0; h < hamleler.length; h++)
if (hamleler[h] === i) { hamleVar = true; break; }
if (hamleVar) kareRenk = HAMLE;
if (tahta[i] !== "" && tahta[i].charAt(1) === "S" && tahta[i].charAt(0) === sahRenk)
kareRenk = SAH_RENK;
gfx.rect(x, y, CELL, CELL, kareRenk);
if (tahta[i] !== "")
{
var tas = tahta[i];
var bgRenk = tas.charAt(0) === "B" ? TAS_BG_B : TAS_BG_S;
var txRenk = tas.charAt(0) === "B" ? TAS_TX_B : TAS_TX_S;
var etiket = tasEtiket(tas);
// taş kutusu
gfx.rect(x + 4, y + 4, CELL - 8, CELL - 8, bgRenk);
// taş yazısı
gfx.text(etiket, x + CELL / 2, y + 10, txRenk, 0.5, 0.0);
}
if (c === 0) gfx.text("" + (8 - r), x + 2, y + 2, TEXT_DIM, 0.0, 0.0);
if (r === 7) gfx.text(String.fromCharCode(65 + c), x + CELL - 8, y + CELL - 10, TEXT_DIM, 0.0, 0.0);
}
}
}
```