Members
(static) ObjRotateLeft
Which sides go to which when rotating left.
- Source:
(static) ObjRotateRight
Which sides go to which when rotating right.
- Source:
Methods
drawBoard()
Draw the board (white and black squares)
This:
- {SvgBoard}
- Source:
drawBorder()
Draw the border
This:
- {SvgBoard}
- Source:
eventGlobal(eventtype, x, y, type)
Events for position. Positions are logical and do
not depend on the flipping of the board.
Types of events: mouseover, mouseout, click and more.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
eventtype |
string | which event happened. |
x |
int | x position of event. |
y |
int | y position of event. |
type |
string | which event happened. |
- Source:
eventPiece(boardPiece, type)
Event handler for events happening on the pieces.
Types of events: click, mouseover and more...
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | instance the event happened on. |
type |
string | the type of event that happened. |
- Source:
eventPosition(piecePosition, rec, type)
Events for position. Positions are logical and do
not depend on the flipping of the board.
Types of events: mouseover, mouseout, click and more.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
piecePosition |
PiecePosition | the position of the event. |
rec |
rect | the Raphael.js rectangle where the event happened. |
type |
string | which is the name of the event that happened. |
- Source:
flip()
Flips the board (see it from the other side)
If the board is 90 deg left it be will 90 deg right.
Black view will turn to white and white to black.
This:
- {SvgBoard}
- Source:
getBoard() → {Board}
get the logical board [Board] associated with this SvgBoard
This:
- {SvgBoard}
- Source:
Returns:
the logical board associated with this SvgBoard.
- Type
- Board
getRec(piecePosition) → {rec}
Return the square at a position.
This method must take into consideraton board rotation
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
piecePosition |
PiecePosition | the logical position for which to return the square. |
- Source:
Returns:
the Raphael.js rec in question.
- Type
- rec
getValue(key) → {anything}
get the config value for a key
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
key |
string | the key to get the config for. |
- Source:
Returns:
the value of the configuration option.
- Type
- anything
glow(boardPiece, glow)
Make a piece glow
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to make glow. |
glow |
object | properties to pass to the glow function as per Raphael.js. |
- Source:
hidePiece(boardPiece)
Quick method to hide a piece
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to hide. |
- Source:
initialize(board, dict) → {SvgBoard}
creates a new instance
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
board |
Board | instance to use as the abstract board. |
dict |
object | overridables to the configuration for this object. |
- Source:
Returns:
the new instance.
- Type
- SvgBoard
newPosition()
Internal method. This method is called whenever
the cursor changes position over the board and ONLY when
it changes position.
No parameters are passed because This method uses:
this.selectedPiece, this.selectedRec, this.lastPos, this.currentPos
to do it's work.
This:
- {SvgBoard}
- Source:
overlay()
Create an overlay rectange for the entire board
This:
- {SvgBoard}
- Source:
pixelsToPos(svgPixelPosition) → {PiecePosition}
Translates pixel position (x,y) to board position (0..7,0..7)
This method must take board rotation into consideration
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
svgPixelPosition |
SvgPixelPosition | object to translate. |
- Source:
Returns:
logical position.
- Type
- PiecePosition
pixelsToPosForgiving(svgPixelPosition) → {PiecePosition}
Forgiving version of the previous function.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
svgPixelPosition |
SvgPixelPosition | object to translate. |
- Source:
Returns:
logical position.
- Type
- PiecePosition
postAddPiece(boardPiece, piecePosition)
Callback method that is called after the logical board adds a piece.
This is where we add the SVG representation of the piece in real graphics.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece that was added. |
piecePosition |
PiecePosition | the position where the piece was added. |
- Source:
postGraphics()
Callback method that is called whenever a piece is added to the board
This method is to be used to do something after a piece is added,
removed etc.
This:
- {SvgBoard}
- Source:
postMovePiece(boardPiece, fromPiecePosition, toPiecePosition)
Callback called when the logical board moves a piece
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to move. |
fromPiecePosition |
PiecePosition | position from which to move. |
toPiecePosition |
PiecePosition | position to which to move. |
- Source:
posToPixels(piecePosition) → {SvgPixelPosition}
Translates position (0..7,0..7) to pixels
This method must take board rotation into consideration
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
piecePosition |
PiecePosition | logical (0..7,0..7) to translate. |
- Source:
Returns:
position in pixels.
- Type
- SvgPixelPosition
postRemovePiece(boardPiece, piecePosition)
Callback method that is called after the logical board removes a piece.
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to add. |
piecePosition |
PiecePosition | the position where the piece was removed. |
- Source:
raphaelPrep()
Prepare the raphael paper so we could do graphics
This:
- {SvgBoard}
- Source:
rectFill(rec, anim)
Fill a rectangle using the default color
This method must take board rotation into consideration
It currently doesn't because the board looks the same in terms
of white/black square when you totally flip it. If we ever support
90% flips then this method must be modified.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
rec |
rect | Raphael.js rectangle object to fill. |
anim |
boolean | do you want animation (slow transition). |
- Source:
redraw(oldview)
Redraw the entire board
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
oldview |
viewType | the old view of the board. |
- Source:
resize(set)
Resize the board
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
set |
set | Raphael set to resize. |
- Source:
rotateleft()
Rotate the board to the left 90 degrees
This:
- {SvgBoard}
- Source:
rotateright()
Rotate the board to the right 90 degrees
This:
- {SvgBoard}
- Source:
showHidePiece(boardPiece, hide)
Shows or hides a given piece according to parameter
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | piece to show or hide. |
hide |
boolean | show or hide the piece. |
- Source:
showPiece(boardPiece)
Quick method to show a piece
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to show. |
- Source:
timeMovePiece(boardPiece, fromPiecePosition, toPiecePosition)
Move a piece on the board (including animation if so configured)
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
boardPiece |
BoardPiece | the piece to move. |
fromPiecePosition |
PiecePosition | position from which to move. |
toPiecePosition |
PiecePosition | position to which to move. |
- Source:
toString() → {string}
toString function
This method is not yet implemented and will throw an exception.
This:
- {SvgBoard}
- Source:
Returns:
a string representation of this object.
- Type
- string
translatePos(pos) → {PiecePosition}
Translate a position from a rectangle position
to a logical position according to board rotation.
This:
- {SvgBoard}
Parameters:
Name | Type | Description |
---|---|---|
pos |
PiecePosition | the position to translate. |
- Source:
Returns:
the logical position.
- Type
- PiecePosition