GithubHelp home page GithubHelp logo

ryancookdev / canvas-chess Goto Github PK

View Code? Open in Web Editor NEW
24.0 6.0 10.0 537 KB

A user interface for chess applications

Home Page: http://www.canvaschess.com

License: MIT License

JavaScript 99.19% HTML 0.81%

canvas-chess's Introduction

Canvas Chess

Canvas Chess is a user interface for building chess applications. Developers can access the HTML5 board using a JavaScript API.

Basic usage:

  1. Include Canvas Chess.
  2. Add a container div.
  3. Create and configure the board.
<script src="canvaschess.js"></script>

<div id="board"></div>

<script>
    var board = new CHESS.Board({
        container: 'board',
        height: '400px',
        width: '400px'
        piece_set: 'img/pieces/merida',
    });
</script>

Board Configuration

When you create a board, you can pass the following configurations settings:

  • container - Required. The id of the div element that will contain the board.
  • height and width - The size of the board in pixels. These are string values ending with 'px'. This is not required, since your application may prefer to set the size dynamically after the board is created.
  • piece_set - Path to the folder containing your piece images, relative to the HTML file. By default, the path 'canvaschess/img/pieces/merida/' will be assumed.
  • fen - The position, in Forsyth–Edwards Notation. Default is the standard starting position.
  • mode - If this value is 'setup', the board will include a piece box. Pieces can be dragged on and off the board.
  • show_labels - True by default. If false, the board will not include letters and numbers. This should be a boolean value, not a string.
  • square_color_light - The color of the light squares. By default #ececd7.
  • square_color_dark - The color of the dark squares. By default #7389b6.
  • square_uri_light and square_uri_dark - If you prefer to use a square graphic instead of a solid color, set the URI to the image file.
  • highlight_hover - False by default. If true, squares will be highlighted as you drag pieces over them. This should be a boolean value, not a string.
  • square_hover_light - If highlight_hover is enabled, light squares will change to this color as you drag over them. By default #b4d990.
  • square_hover_dark - If highlight_hover is enabled, dark squares will change to this color as you drag over them. By default #85c249.
  • highlight_move - False by default. If true, the last move with be highlighted (both start and end square). This should be a boolean value, not a string.
  • highlight_move_color - If highlight_move is enabled, the start and end square of the previous move will be highlighted with this color. By default #ff0000.
  • highlight_move_opacity - If highlight_move is enabled, the highlight color will be transparent or opaque based on this value. This should be between '0' (fully transparent) and '1' (fully opaque). By default '0.5'.
  • gc_opacity - Canvas Chess supports graphic commentary (colored arrows and squares drawn on the board). If this feature is used, then this value will determine the opacity of the arrows and squares. This should be between '0' (fully transparent) and '1' (fully opaque). By default '0.8'.

canvas-chess's People

Contributors

bennedik avatar ryancookdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

canvas-chess's Issues

CHESS.Board.move() does not handle moves with pawn promotions

If you create a chessboard, and then call the move method with a move in standard algebraic notation, which is a pawn promotion, e.g. "e8=Q", the move is not handled correctly and the pawn is not promoted.

Looking at the source code, the $.LongNotation.getLongNotation method does not support pawn promotions, and the Board.model.move method doesn't either, however there seems to be support for pawn promotions in the $.BoardMover.move method.

Bug in IE?

Hi there,
First I would like to thank you for setting up this great framework. So simple to use with great results.
However, in Internet Explorer 11 people are claiming not to see the moves. Indeed, also at Angry Bishop this can be seen. Weirdly, pressing Ctrl+F5 (removing cache) works... sometimes!
Is this something you've encountered before and what would you advise? Not to use IE altogether?

Many thanks in advance,
Bert Hollander

rmarkdown

I am interested in using this for rmarkdown in rstudio. Does this work?

Castling

I'd appreciate it if this excellent little programme could tolerate zeros in castling notation. Capital 'O' (O-O and O-O-O) are correct for PGN but FIDE specify zeroes (0-0 and 0-0-0), and so an awful lot of "PGN" files out there use zeros -- for example, those produced by ChessBase. (I've also contacted ChessBase.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.