-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFigure.qml
40 lines (31 loc) · 1.26 KB
/
Figure.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import QtQuick 2.0
Item {
id: figure
property var kind: "bp"
property var row: 0
property var col: 0
property bool alive: true
Image {
id: img
source: {
if (kind == "bp") {return "images/black/pawn.svg"}
if (kind == "bb") {return "images/black/bishop.svg"}
if (kind == "br") {return "images/black/rook.svg"}
if (kind == "bh") {return "images/black/horse.svg"}
if (kind == "bq") {return "images/black/queen.svg"}
if (kind == "bk") {return "images/black/king.svg"}
if (kind == "wp") {return "images/white/pawn.svg"}
if (kind == "wb") {return "images/white/bishop.svg"}
if (kind == "wr") {return "images/white/rook.svg"}
if (kind == "wh") {return "images/white/horse.svg"}
if (kind == "wq") {return "images/white/queen.svg"}
if (kind == "wk") {return "images/white/king.svg"}
}
// make the figures 70% of the rectangle
width: (body.blockSizeX * 0.7)
height: (body.blockSizeY * 0.7)
// Calculate the xy coordinates based on the position
y: row * body.blockSizeY + (body.blockSizeY * 0.15)
x: col * body.blockSizeX + (body.blockSizeX * 0.15)
}
}