flutter: squareSide 改名为 squareWidth

This commit is contained in:
Calcitem 2020-11-07 01:07:38 +08:00
parent 8479487295
commit bdd0f2a12d
3 changed files with 43 additions and 42 deletions

View File

@ -15,9 +15,9 @@ class BoardPainter extends PainterBase {
canvas,
thePaint,
gridWidth,
squareSide,
offsetX: BoardWidget.padding + squareSide / 2,
offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareSide / 2,
squareWidth,
offsetX: BoardWidget.padding + squareWidth / 2,
offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareWidth / 2,
);
}
@ -30,7 +30,7 @@ class BoardPainter extends PainterBase {
Canvas canvas,
Paint paint,
double gridWidth,
double squareSide, {
double squareWidth, {
double offsetX,
double offsetY,
}) {
@ -46,7 +46,7 @@ class BoardPainter extends PainterBase {
canvas.drawRect(
//Rect.fromLTWH(left, top, gridWidth, squareSide * 6),
Rect.fromLTWH(left, top, squareSide * 6, squareSide * 6),
Rect.fromLTWH(left, top, squareWidth * 6, squareWidth * 6),
paint,
);
@ -55,108 +55,108 @@ class BoardPainter extends PainterBase {
// 线 ()
canvas.drawLine(
Offset(left + squareSide * 1, top + squareSide * 1),
Offset(left + squareSide * 5, top + squareSide * 1),
Offset(left + squareWidth * 1, top + squareWidth * 1),
Offset(left + squareWidth * 5, top + squareWidth * 1),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 2, top + squareSide * 2),
Offset(left + squareSide * 4, top + squareSide * 2),
Offset(left + squareWidth * 2, top + squareWidth * 2),
Offset(left + squareWidth * 4, top + squareWidth * 2),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 2, top + squareSide * 4),
Offset(left + squareSide * 4, top + squareSide * 4),
Offset(left + squareWidth * 2, top + squareWidth * 4),
Offset(left + squareWidth * 4, top + squareWidth * 4),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 1, top + squareSide * 5),
Offset(left + squareSide * 5, top + squareSide * 5),
Offset(left + squareWidth * 1, top + squareWidth * 5),
Offset(left + squareWidth * 5, top + squareWidth * 5),
paint,
);
// 线 ()
canvas.drawLine(
Offset(left, top + squareSide * 3),
Offset(left + squareSide * 2, top + squareSide * 3),
Offset(left, top + squareWidth * 3),
Offset(left + squareWidth * 2, top + squareWidth * 3),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 4, top + squareSide * 3),
Offset(left + squareSide * 6, top + squareSide * 3),
Offset(left + squareWidth * 4, top + squareWidth * 3),
Offset(left + squareWidth * 6, top + squareWidth * 3),
paint,
);
// 线 ()
canvas.drawLine(
Offset(left + squareSide * 1, top + squareSide * 1),
Offset(left + squareSide * 1, top + squareSide * 5),
Offset(left + squareWidth * 1, top + squareWidth * 1),
Offset(left + squareWidth * 1, top + squareWidth * 5),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 2, top + squareSide * 2),
Offset(left + squareSide * 2, top + squareSide * 4),
Offset(left + squareWidth * 2, top + squareWidth * 2),
Offset(left + squareWidth * 2, top + squareWidth * 4),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 4, top + squareSide * 2),
Offset(left + squareSide * 4, top + squareSide * 4),
Offset(left + squareWidth * 4, top + squareWidth * 2),
Offset(left + squareWidth * 4, top + squareWidth * 4),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 5, top + squareSide * 1),
Offset(left + squareSide * 5, top + squareSide * 5),
Offset(left + squareWidth * 5, top + squareWidth * 1),
Offset(left + squareWidth * 5, top + squareWidth * 5),
paint,
);
// 线 ()
canvas.drawLine(
Offset(left + squareSide * 3, top),
Offset(left + squareSide * 3, top + squareSide * 2),
Offset(left + squareWidth * 3, top),
Offset(left + squareWidth * 3, top + squareWidth * 2),
paint,
);
canvas.drawLine(
Offset(left + squareSide * 3, top + squareSide * 4),
Offset(left + squareSide * 3, top + squareSide * 6),
Offset(left + squareWidth * 3, top + squareWidth * 4),
Offset(left + squareWidth * 3, top + squareWidth * 6),
paint,
);
// 线
canvas.drawLine(
Offset(left + 0, top),
Offset(left + squareSide * 2, top + squareSide * 2),
Offset(left + squareWidth * 2, top + squareWidth * 2),
paint,
);
// 线
canvas.drawLine(
Offset(left + squareSide * 4, top + squareSide * 4),
Offset(left + squareSide * 6, top + squareSide * 6),
Offset(left + squareWidth * 4, top + squareWidth * 4),
Offset(left + squareWidth * 6, top + squareWidth * 6),
paint,
);
// 线
canvas.drawLine(
Offset(left + squareSide * 6, top),
Offset(left + squareSide * 4, top + squareSide * 2),
Offset(left + squareWidth * 6, top),
Offset(left + squareWidth * 4, top + squareWidth * 2),
paint,
);
// 线
canvas.drawLine(
Offset(left + squareSide * 2, top + squareSide * 4),
Offset(left + squareSide * 0, top + squareSide * 6),
Offset(left + squareWidth * 2, top + squareWidth * 4),
Offset(left + squareWidth * 0, top + squareWidth * 6),
paint,
);
}

View File

@ -7,9 +7,10 @@ abstract class PainterBase extends CustomPainter {
final double width;
final thePaint = Paint();
final gridWidth, squareSide;
final gridWidth;
final squareWidth;
PainterBase({@required this.width})
: gridWidth = (width - BoardWidget.padding * 2),
squareSide = (width - BoardWidget.padding * 2) / 7;
squareWidth = (width - BoardWidget.padding * 2) / 7;
}

View File

@ -26,7 +26,7 @@ class PiecesPainter extends PainterBase {
this.blurIndex = Move.InvalidIndex,
}) : super(width: width) {
//
pieceSide = squareSide * 0.9; //
pieceSide = squareWidth * 0.9; //
}
@override
@ -37,11 +37,11 @@ class PiecesPainter extends PainterBase {
thePaint,
position: position,
gridWidth: gridWidth,
squareSide: squareSide,
squareSide: squareWidth,
pieceSide: pieceSide,
// 线
offsetX: BoardWidget.padding + squareSide / 2,
offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareSide / 2,
offsetX: BoardWidget.padding + squareWidth / 2,
offsetY: BoardWidget.padding + BoardWidget.digitsHeight + squareWidth / 2,
focusIndex: focusIndex,
blurIndex: blurIndex,
);