Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/laat/chess-board
A Web Component for displaying chess positions
https://github.com/laat/chess-board
Last synced: 2 months ago
JSON representation
A Web Component for displaying chess positions
- Host: GitHub
- URL: https://github.com/laat/chess-board
- Owner: laat
- License: mit
- Created: 2014-03-03T02:36:41.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2020-02-28T11:22:26.000Z (over 4 years ago)
- Last Synced: 2024-03-24T13:42:16.143Z (3 months ago)
- Language: HTML
- Size: 1.9 MB
- Stars: 20
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Lists
- awesome-chess - chess-board - A web component for displaying chess positions, repo on GitHub. (Chess boards)
- awesome-chess - chess-board - A web component for displaying chess positions. It takes FEN string as input and renders the board as output. (Uncategorized / Uncategorized)
README
# <chess-board> [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/chess-board.svg?style=flat
[npm-url]: https://npmjs.org/package/chess-board
[travis-image]: https://img.shields.io/travis/laat/chess-board.svg?style=flat
[travis-url]: https://travis-ci.org/laat/chess-board> A web component for displaying chess positions.
## Demo
> [Check it live](http://laat.github.io/chess-board).
## Usage
1. Import Web Components' polyfill:
```html
```2. Import Custom Element:
```html
```3. Start using it!
```html
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
```## Options
Attribute | Description
--- | ---
`unicode` | Display chess pices with unicode characters.
`frame` | Display file and rank arround the chessboard
`reverse` | Display the chessboard with black pieces at the bottom.## Methods
### put()
Put the white queen on the a4 square
```js
var board = new ChessBoard();
board.put("a4", "Q");
```set a4 square empty
```js
var board = new ChessBoard();
board.put("a4", "");
```### move()
move a piece from a4 to a1
```js
var board = new ChessBoard();
board.move("a4", "a1");
```The pieces are defined as in [Forsyth–Edwards Notation](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation)
```js
P // ♙ white pawn
N // ♘ white knight
B // ♗ white bishop
R // ♖ white rook
Q // ♕ white queen
K // ♔ white kingp // ♟ black pawn
n // ♞ black knight
b // ♝ black bishop
r // ♜ black rook
q // ♛ black queen
k // ♚ black king
```### clearBoard()
```js
var board = new ChessBoard();
board.clearBoard();
```### setting board position
```js
var board = new ChessBoard();
board.fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
```### getting board position
```js
var board = new ChessBoard();
board.fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR";
board.move("a2", "a3");var currentFen = board.fen;
```## License
MIT © [Sigurd Fosseng](https://github.com/laat)