0.0.17 • Published 4 years ago

canvas-chessboard v0.0.17

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

canvas-chessboard

This library is in pre-release, every help, collaborations and tips are welcome! you feel free to track anything

version 0.0.16 Breaking changes

  • Figurine is no more an enum but a literal string type!
  • Colors is no more an enum but a literal string type!

Use

install

# if you use yarn:
yarn add canvas-chessboard

# if you use npm:
npm install canvas-chessboard --save

import font

/* add in your SCSS file (check the correct path): */
@import "./node_modules/canvas-chessboard/dist/fonts/ScacchiPainter.scss";

import js module

/* typescript */
import * as CB from "canvas-chessboard/modules/es2018/canvasChessBoard";

render

/* typescript */
const CELLCOLORS: [string, string] = ["#fff", "#C5CACA"];
const PIECECOLORS: [string, string] = ["#fff", "#333"];
var cb = new CB.CanvasChessBoard(canvas, {
  CELLCOLORS,
  PIECECOLORS,
  BORDER_SIZE: 1,
});

const pieces: Array<CB.Piece> = [
  {
    figurine: "k",
    color: "white",
    loc: { col: CB.BoardFile.A, row: CB.BoardRank.R1 },
  },
  {
    figurine: "k",
    color: "black",
    loc: { col: CB.BoardFile.H, row: CB.BoardRank.R8 },
  },
];
cb.SetPieces(pieces);
cb.Redraw();

Changing aspect of pieces

import Configs from "canvas-chessboard/modules/es2018/presets";
// in the setup of canvas:
const cfgKey = "Sample_ScacchiPainter";
cb.AddFontConfig(cfgKey, Configs.ScacchiPainter);

// somewhere else in the code
cb.SetFont(cfgKey);
cb.Redraw();
0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago