chess-board-canvas

1.0.2 • Public • Published

Chess Canvas

Подключение

<link rel="stylesheet" type="text/css" href="chessBoard.css">

<!-- Библиотека chess.js -->
<script type="text/javascript" src="chess.js"></script>

<script type="text/javascript" src="fenParser.js"></script>
<script type="text/javascript" src="ChessBoard.js"></script>

Include as es6 Module

import ChessBoard from 'chess-board-canvas'

Использование

var board = new ChessBoard(document.body, {
    color : 'w'
  , fen   :'rnbqkbnr/ppp2ppp/8/3pp3/3PP3/8/PPP1KPPP/RNBQ1BNR b kq - 1 3'
  , skin  : 'default'
});

// Событие инициализации
board.onInit = function () {
  board.resize(700); // Зименение размера доски
};


// Текущее состояние
board.fen();
// -> 1r3kr1/pbpBBp1p/1b3P2/8/8/2P2q2/P4PPP/3R2K1 b - - 0 24

// Ход
board.move({ from: 'g2', to: 'g3' });
// -> { color: 'w', from: 'g2', to: 'g3', flags: 'n', piece: 'p', san: 'g3' }


// Рисование стрелки
board.arrow('d2', 'f6', '25%');
// 1

// Рисование стрелки
board.arrow('e2', 'f4', '30%');
// 2

// Удаление стрелки по ID
board.removeArrow(1);


// Удаление всех стрелок
board.removeAllArrows();


Readme

Keywords

Package Sidebar

Install

npm i chess-board-canvas

Weekly Downloads

0

Version

1.0.2

License

ISC

Last publish

Collaborators

  • vocxod