flutter: board/board_painter.dart 小重构

This commit is contained in:
Calcitem 2020-11-07 12:14:59 +08:00
parent 14e15a1430
commit 30c996a10a
1 changed files with 13 additions and 12 deletions

View File

@ -38,21 +38,22 @@ class BoardPainter extends PainterBase {
paint.color = ColorConst.boardLineColor;
paint.style = PaintingStyle.stroke;
const double borderLineWidth = 2.0;
const double innerLineWidth = 1.0;
var left = offsetX;
var top = offsetY;
//
paint.strokeWidth = 2;
paint.strokeWidth = borderLineWidth;
canvas.drawRect(
//Rect.fromLTWH(left, top, gridWidth, squareSide * 6),
Rect.fromLTWH(left, top, squareWidth * 6, squareWidth * 6),
paint,
);
paint.strokeWidth = 1;
paint.strokeWidth = innerLineWidth;
// 线 ()
// Horizontal lines (Top to Bottom)
canvas.drawLine(
Offset(left + squareWidth * 1, top + squareWidth * 1),
@ -78,7 +79,7 @@ class BoardPainter extends PainterBase {
paint,
);
// 线 ()
// Middle horizontal lines (Left to Right)
canvas.drawLine(
Offset(left, top + squareWidth * 3),
@ -92,7 +93,7 @@ class BoardPainter extends PainterBase {
paint,
);
// 线 ()
// Ordinate Lines (Left to Right)
canvas.drawLine(
Offset(left + squareWidth * 1, top + squareWidth * 1),
@ -118,7 +119,7 @@ class BoardPainter extends PainterBase {
paint,
);
// 线 ()
// Middle horizontal lines (Top to Bottom)
canvas.drawLine(
Offset(left + squareWidth * 3, top),
@ -132,28 +133,28 @@ class BoardPainter extends PainterBase {
paint,
);
// 线
// top left oblique line
canvas.drawLine(
Offset(left + 0, top),
Offset(left + squareWidth * 2, top + squareWidth * 2),
paint,
);
// 线
// lower right oblique line
canvas.drawLine(
Offset(left + squareWidth * 4, top + squareWidth * 4),
Offset(left + squareWidth * 6, top + squareWidth * 6),
paint,
);
// 线
// top right oblique line
canvas.drawLine(
Offset(left + squareWidth * 6, top),
Offset(left + squareWidth * 4, top + squareWidth * 2),
paint,
);
// 线
// lower left oblique line
canvas.drawLine(
Offset(left + squareWidth * 2, top + squareWidth * 4),
Offset(left + squareWidth * 0, top + squareWidth * 6),