stagexl_interactive_chessboard 1.1.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 56

StageXL Interactive Chessboard #

An interactive chessboard written for StageXL which allows players to move pieces.

alt text

Example #

Chessboard board = Chessboard();
stage.addChild(board);

It is fully compatible with chess.dart #

Chess.Chess chess = Chess.Chess()
  ..move("e3")
  ..move("e5")
  ..move("Qe2")
  ..move("d5");
board.loadFromChessObject(chess);

Any square can have its background color set #

board.resetAllSquareColors();
board.setSquareBackgroundColor("e1", 0xaa27b243);

Capture when squares are clicked #

board.onSquareClicked.listen((ChessEvent event) {
  print(event.squareName);
});

Show and hide the labels around the board #

board.showLabels = true;

Change which way round the board is #

board.blackAtTop = false;

1.1.0 - 25/02/2018. #

  • decoupled square from chessboard so it can be used independantly.

1.0.0 - 20/02/2018. #

  • Initial version

example/main.dart

import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';
import 'package:stagexl_interactive_chessboard/stagexl_interactive_chessboard.dart';
import 'dart:math';
import 'package:chess/chess.dart' as Chess;

Stage stage;

Future<Null> main() async {
  StageOptions options = StageOptions()
    ..backgroundColor = Color.White
    ..stageScaleMode =StageScaleMode.NO_SCALE
    ..stageAlign =StageAlign.TOP_LEFT
    ..renderEngine = RenderEngine.WebGL;

  var canvas = html.querySelector('#stage');
  stage = Stage(canvas, width: 1280, height: 800, options: options);

  var renderLoop = RenderLoop();
  renderLoop.addStage(stage);

  Chessboard board = Chessboard();
  stage.addChild(board);
  board.blackAtTop = false;
  num size = min(stage.stageWidth, stage.stageHeight);
  size -= 20;
  board.setSize(size, size);

  board.x = (stage.stageWidth - board.width) / 2;
  board.y = (stage.stageHeight - board.height) / 2;
  
  Chess.Chess chess = Chess.Chess()
    ..move("e3")
    ..move("e5")
    ..move("Qe2")
    ..move("d5");
  board.loadFromChessObject(chess);

  board.onSquareClicked.listen((ChessEvent event) {
    board.resetAllSquareColors();
    board.setSquareBackgroundColor(event.squareName, 0xaa27b243);

    List<Chess.Move> moves = chess.generate_moves({"square": event.squareName});
    for (Chess.Move move in moves) {
      board.setSquareBackgroundColor(move.to, 0xaaffffb2);
    }
  });
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  stagexl_interactive_chessboard: ^1.1.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:stagexl_interactive_chessboard/stagexl_interactive_chessboard.dart';
  
Version Uploaded Documentation Archive
1.1.0 Feb 25, 2019 Go to the documentation of stagexl_interactive_chessboard 1.1.0 Download stagexl_interactive_chessboard 1.1.0 archive
1.0.0 Feb 20, 2019 Go to the documentation of stagexl_interactive_chessboard 1.0.0 Download stagexl_interactive_chessboard 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
13
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

We analyzed this package on Mar 6, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: web

Primary library: package:stagexl_interactive_chessboard/stagexl_interactive_chessboard.dart with components: html.

Health suggestions

Fix lib/src/Chessboard.dart. (-1 points)

Analysis of lib/src/Chessboard.dart reported 2 hints:

line 45 col 3: Avoid return types on setters.

line 54 col 3: Avoid return types on setters.

Fix lib/src/BottomLabels.dart. (-0.50 points)

Analysis of lib/src/BottomLabels.dart reported 1 hint:

line 8 col 3: Avoid return types on setters.

Fix lib/src/LeftLabels.dart. (-0.50 points)

Analysis of lib/src/LeftLabels.dart reported 1 hint:

line 8 col 3: Avoid return types on setters.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/ChessEvent.dart (Run dartfmt to format lib/src/ChessEvent.dart.)
  • lib/src/PieceFactory.dart (Run dartfmt to format lib/src/PieceFactory.dart.)
  • lib/stagexl_interactive_chessboard.dart (Run dartfmt to format lib/stagexl_interactive_chessboard.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
chess ^0.6.5 0.6.5
stagexl ^1.1.0 1.4.0+2
stagexl_chess_pieces ^1.0.1 1.0.1
Transitive dependencies
charcode 1.1.2
collection 1.14.11
convert 2.1.1
petitparser 2.2.0
typed_data 1.1.6
xml 3.4.0