Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib/customs/graphical_board.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/customs/graphical_board.js')
-rw-r--r--lib/customs/graphical_board.js35
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/customs/graphical_board.js b/lib/customs/graphical_board.js
index a6ca655..f44c993 100644
--- a/lib/customs/graphical_board.js
+++ b/lib/customs/graphical_board.js
@@ -6,7 +6,34 @@ GraphicalBoard.prototype = {
initialize: function(pos, cellSize, stage){
this.pos = pos;
this.cellSize = cellSize;
+ this.coordsFontSize = cellSize * 0.7;
this.stage = stage;
+ var addSimpleCoord = function(self, textValue, position){
+ var text = new createjs.Text(textValue, self.coordsFontSize + "px Arial bold", "#000");
+ text.x = position[0];
+ text.y = position[1];
+ self.stage.addChild(text);
+ return [text.getMeasuredWidth(), text.getMeasuredHeight()];
+ };
+ var addCoordsTexts = function(self){
+ self.coordsTextDim = addSimpleCoord(self, "1", [self.pos[0], self.pos[1] + 7*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "2", [self.pos[0], self.pos[1] + 6*self.cellSize + self.cellSize * 0.1]);
+ self.coordsTextWidth = addSimpleCoord(self, "3", [self.pos[0], self.pos[1] + 5*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "4", [self.pos[0], self.pos[1] + 4*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "5", [self.pos[0], self.pos[1] + 3*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "6", [self.pos[0], self.pos[1] + 2*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "7", [self.pos[0], self.pos[1] + 1*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "8", [self.pos[0], self.pos[1] + 0*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "A", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 0 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "B", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 1 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "C", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 2 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "D", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 3 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "E", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 4 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "F", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 5 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "G", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 6 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ addSimpleCoord(self, "H", [self.pos[0] + self.coordsTextDim[0] + self.cellSize * 0.4 + 7 * self.cellSize, self.pos[1] + 8*self.cellSize + self.cellSize * 0.1]);
+ };
+ addCoordsTexts(this);
},
getX: function(){
return this.pos[0];
@@ -19,12 +46,18 @@ GraphicalBoard.prototype = {
},
// file : (0..7)
getFileX: function(file){
- return this.pos[0] + file * this.cellSize;
+ return this.pos[0] + this.coordsTextDim[0] + this.cellSize * 0.2 + file * this.cellSize;
},
// rank : (0..7)
getRankY: function(rank){
return this.pos[1] + (7-rank) * this.cellSize;
},
+ getWidth: function(){
+ return this.coordsTextDim[0] + this.cellSize * 0.2 + 8 * this.cellSize;
+ },
+ getHeight: function(){
+ return this.cellSize * 0.2 + this.coordsTextDim[1] + 8 * this.cellSize;
+ },
// Just call it once.
addToStage: function(){
for (var rank = 0; rank < 8; rank++){