flutter: 增加部分画X的代码 (WIP)

This commit is contained in:
Calcitem 2020-11-15 23:33:18 +08:00
parent 75e9787ab0
commit 43a9eff2d8
3 changed files with 34 additions and 14 deletions

View File

@ -128,21 +128,34 @@ class PiecesPainter extends PainterBase {
var pieceInnerRadius = pieceRadius * 0.99; //
//
paint.color = Piece.isWhite(pps.piece)
? Properties.whitePieceBorderColor
: Properties.blackPieceBorderColor;
switch (pps.piece) {
case Piece.blackStone:
paint.color = Properties.blackPieceBorderColor;
canvas.drawCircle(pps.pos, pieceRadius, paint); //
//
//
paint.color = Piece.isWhite(pps.piece)
? Properties.whitePieceColor
: Properties.blackPieceColor;
//paint.color = ColorConst.WhitePieceColor;
paint.color = Properties.blackPieceColor;
canvas.drawCircle(pps.pos, pieceInnerRadius, paint);
break;
case Piece.whiteStone:
paint.color = Properties.whitePieceBorderColor;
canvas.drawCircle(pps.pos, pieceRadius, paint); //
paint.color = Properties.whitePieceColor;
canvas.drawCircle(pps.pos, pieceInnerRadius, paint);
break;
case Piece.ban:
print("pps.piece is Ban");
paint.color = Properties.banBorderColor;
// TODO
paint.color = Properties.banColor;
canvas.drawLine(new Offset(0, 0),
new Offset(pieceInnerRadius, pieceInnerRadius), paint);
canvas.drawLine(new Offset(pieceInnerRadius, 0),
new Offset(0, pieceInnerRadius), paint);
break;
default:
assert(false);
break;
}
/*
final textSpan = TextSpan(text: Piece.Names[pps.piece], style: textStyle);

View File

@ -48,5 +48,8 @@ class Properties {
static const whitePieceColor = Color.fromARGB(0xFF, 0xFF, 0xFF, 0xFF);
static const whitePieceBorderColor = Color.fromARGB(0xFF, 0x66, 0x00, 0x00);
static const banColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00);
static const banBorderColor = Color.fromARGB(0x80, 0xFF, 0x00, 0x00);
static const pieceTextColor = Color.fromARGB(0xCC, 0xFF, 0xFF, 0xFF);
}

View File

@ -95,6 +95,10 @@ class Piece {
static bool isBlack(String c) => '@'.contains(c);
static bool isWhite(String c) => 'O'.contains(c);
static bool isBan(String c) => 'X'.contains(c);
static bool isEmpty(String c) => '*'.contains(c);
}
class Move {