flutter: pieceSide/squareSide 改名为 pieceWidth/squareWidth

This commit is contained in:
Calcitem 2020-11-07 07:35:36 +08:00
parent f6710e800e
commit 538d32bc78
1 changed files with 16 additions and 16 deletions

View File

@ -17,7 +17,7 @@ class PiecesPainter extends PainterBase {
final Position position; final Position position;
final int focusIndex, blurIndex; final int focusIndex, blurIndex;
double pieceSide; double pieceWidth;
PiecesPainter({ PiecesPainter({
@required double width, @required double width,
@ -26,7 +26,7 @@ class PiecesPainter extends PainterBase {
this.blurIndex = Move.invalidIndex, this.blurIndex = Move.invalidIndex,
}) : super(width: width) { }) : super(width: width) {
// //
pieceSide = squareWidth * 0.9; // pieceWidth = squareWidth * 0.9; //
} }
@override @override
@ -37,8 +37,8 @@ class PiecesPainter extends PainterBase {
thePaint, thePaint,
position: position, position: position,
gridWidth: gridWidth, gridWidth: gridWidth,
squareSide: squareWidth, squareWidth: squareWidth,
pieceSide: pieceSide, pieceWidth: pieceWidth,
// 线 // 线
offsetX: BoardWidget.padding + squareWidth / 2, offsetX: BoardWidget.padding + squareWidth / 2,
offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareWidth / 2, offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareWidth / 2,
@ -58,8 +58,8 @@ class PiecesPainter extends PainterBase {
Paint paint, { Paint paint, {
Position position, Position position,
double gridWidth, double gridWidth,
double squareSide, double squareWidth,
double pieceSide, double pieceWidth,
double offsetX, double offsetX,
double offsetY, double offsetY,
int focusIndex = Move.invalidIndex, int focusIndex = Move.invalidIndex,
@ -75,18 +75,18 @@ class PiecesPainter extends PainterBase {
// //
for (var row = 0; row < 7; row++) { 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; 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)); piecesToDraw.add(PiecePaintStub(piece: piece, pos: pos));
shadowPath.addOval( 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.whitePieceBorderColor
: ColorConst.blackPieceBorderColor; : ColorConst.blackPieceBorderColor;
canvas.drawCircle(pps.pos, pieceSide / 2, paint); // canvas.drawCircle(pps.pos, pieceWidth / 2, paint); //
// //
paint.color = Piece.isWhite(pps.piece) paint.color = Piece.isWhite(pps.piece)
@ -118,7 +118,7 @@ class PiecesPainter extends PainterBase {
: ColorConst.blackPieceColor; : ColorConst.blackPieceColor;
//paint.color = ColorConst.WhitePieceColor; //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); final textSpan = TextSpan(text: Piece.Names[pps.piece], style: textStyle);
@ -149,8 +149,8 @@ class PiecesPainter extends PainterBase {
paint.strokeWidth = 2; paint.strokeWidth = 2;
canvas.drawCircle( canvas.drawCircle(
Offset(left + column * squareSide, top + row * squareSide), Offset(left + column * squareWidth, top + row * squareWidth),
pieceSide / 2, pieceWidth / 2,
paint, paint,
); );
} }
@ -163,8 +163,8 @@ class PiecesPainter extends PainterBase {
paint.style = PaintingStyle.fill; paint.style = PaintingStyle.fill;
canvas.drawCircle( canvas.drawCircle(
Offset(left + column * squareSide, top + row * squareSide), Offset(left + column * squareWidth, top + row * squareWidth),
pieceSide / 2 * 0.8, pieceWidth / 2 * 0.8,
paint, paint,
); );
} }