new Canvas(elem, opt, images)
Create a jGoBoard canvas object.
Parameters:
Name | Type | Description |
---|---|---|
elem |
Object | Container HTML element or its id. |
opt |
Object | Options object. |
images |
Object | Set of images (or false values) for drawing. |
Members
getCoordinate
Get board coordinate based on screen coordinates.
Methods
addListener(event, callback)
Add an event listener to canvas (click) events. The callback will be
called with 'this' referring to Canvas object, with coordinate and
event as parameters. Supported event types are 'click', 'mousemove',
and 'mouseout'. With 'mouseout', there is no coordinate parameter for
callback.
Parameters:
Name | Type | Description |
---|---|---|
event |
String | The event to listen to, e.g. 'click'. |
callback |
function | The callback. |
draw(jboard, i1, j1, i2, j2)
Redraw canvas portion using a board.
Parameters:
Name | Type | Description |
---|---|---|
jboard |
Board | Board object. |
i1 |
number | Starting column to be redrawn. |
j1 |
number | Starting row to be redrawn. |
i2 |
number | Ending column to be redrawn (inclusive). |
j2 |
number | Ending row to be redrawn (inclusive). |
getX() → {number}
Get X coordinate based on column.
Returns:
Coordinate.
- Type
- number
getY() → {number}
Get Y coordinate based on row.
Returns:
Coordinate.
- Type
- number
restore()
Restore portion of canvas.