From 538d32bc78482e738bdd83c95285a0900e518b63 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Sat, 7 Nov 2020 07:35:36 +0800 Subject: [PATCH] =?UTF-8?q?flutter:=20pieceSide/squareSide=20=E6=94=B9?= =?UTF-8?q?=E5=90=8D=E4=B8=BA=20pieceWidth/squareWidth?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ui/flutter/lib/board/pieces-painter.dart | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ui/flutter/lib/board/pieces-painter.dart b/src/ui/flutter/lib/board/pieces-painter.dart index 2b65e1bf..10677461 100644 --- a/src/ui/flutter/lib/board/pieces-painter.dart +++ b/src/ui/flutter/lib/board/pieces-painter.dart @@ -17,7 +17,7 @@ class PiecesPainter extends PainterBase { final Position position; final int focusIndex, blurIndex; - double pieceSide; + double pieceWidth; PiecesPainter({ @required double width, @@ -26,7 +26,7 @@ class PiecesPainter extends PainterBase { this.blurIndex = Move.invalidIndex, }) : super(width: width) { // - pieceSide = squareWidth * 0.9; // 棋子大小 + pieceWidth = squareWidth * 0.9; // 棋子大小 } @override @@ -37,8 +37,8 @@ class PiecesPainter extends PainterBase { thePaint, position: position, gridWidth: gridWidth, - squareSide: squareWidth, - pieceSide: pieceSide, + squareWidth: squareWidth, + pieceWidth: pieceWidth, // 棋子放在线上中央 offsetX: BoardWidget.padding + squareWidth / 2, offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareWidth / 2, @@ -58,8 +58,8 @@ class PiecesPainter extends PainterBase { Paint paint, { Position position, double gridWidth, - double squareSide, - double pieceSide, + double squareWidth, + double pieceWidth, double offsetX, double offsetY, int focusIndex = Move.invalidIndex, @@ -75,18 +75,18 @@ class PiecesPainter extends PainterBase { // 在棋盘上画棋子 for (var row = 0; row < 7; row++) { // - for (var column = 0; column < 7; column++) { + for (var col = 0; col < 7; col++) { // - final piece = position.pieceAt(row * 7 + column); // 改为9则全空 + final piece = position.pieceAt(row * 7 + col); // 改为9则全空 if (piece == Piece.noPiece) continue; - var pos = Offset(left + squareSide * column, top + squareSide * row); + var pos = Offset(left + squareWidth * col, top + squareWidth * row); piecesToDraw.add(PiecePaintStub(piece: piece, pos: pos)); shadowPath.addOval( - Rect.fromCenter(center: pos, width: pieceSide, height: pieceSide), + Rect.fromCenter(center: pos, width: pieceWidth, height: pieceWidth), ); } } @@ -110,7 +110,7 @@ class PiecesPainter extends PainterBase { ? ColorConst.whitePieceBorderColor : ColorConst.blackPieceBorderColor; - canvas.drawCircle(pps.pos, pieceSide / 2, paint); // 临时调试用 + canvas.drawCircle(pps.pos, pieceWidth / 2, paint); // 临时调试用 // 棋子颜色 paint.color = Piece.isWhite(pps.piece) @@ -118,7 +118,7 @@ class PiecesPainter extends PainterBase { : ColorConst.blackPieceColor; //paint.color = ColorConst.WhitePieceColor; - canvas.drawCircle(pps.pos, pieceSide * 0.8 / 2, paint); // 决定棋子外圈有宽 + canvas.drawCircle(pps.pos, pieceWidth * 0.8 / 2, paint); // 决定棋子外圈有宽 /* final textSpan = TextSpan(text: Piece.Names[pps.piece], style: textStyle); @@ -149,8 +149,8 @@ class PiecesPainter extends PainterBase { paint.strokeWidth = 2; canvas.drawCircle( - Offset(left + column * squareSide, top + row * squareSide), - pieceSide / 2, + Offset(left + column * squareWidth, top + row * squareWidth), + pieceWidth / 2, paint, ); } @@ -163,8 +163,8 @@ class PiecesPainter extends PainterBase { paint.style = PaintingStyle.fill; canvas.drawCircle( - Offset(left + column * squareSide, top + row * squareSide), - pieceSide / 2 * 0.8, + Offset(left + column * squareWidth, top + row * squareWidth), + pieceWidth / 2 * 0.8, paint, ); }