diff --git a/lib/src/models.dart b/lib/src/models.dart index c3ac5be..3d09834 100644 --- a/lib/src/models.dart +++ b/lib/src/models.dart @@ -405,11 +405,15 @@ class Arrow implements Shape { final Color color; final SquareId orig; final SquareId dest; + /// Width of the arrow and size of its tip will be scaled by this factor. + /// If 1.0, the width will be squareSize/4 + final double scale; const Arrow({ required this.color, required this.orig, required this.dest, + this.scale = 1.0, }); @override diff --git a/lib/src/widgets/shape.dart b/lib/src/widgets/shape.dart index 944a1b0..2bb4c97 100644 --- a/lib/src/widgets/shape.dart +++ b/lib/src/widgets/shape.dart @@ -25,6 +25,7 @@ class ShapeWidget extends StatelessWidget { color: final color, orig: final orig, dest: final dest, + scale: final scale, ) => SizedBox.square( dimension: boardSize, @@ -34,6 +35,7 @@ class ShapeWidget extends StatelessWidget { orientation, Coord.fromSquareId(orig), Coord.fromSquareId(dest), + scale, ), ), ), @@ -62,17 +64,19 @@ class ShapeWidget extends StatelessWidget { } class _ArrowPainter extends CustomPainter { - _ArrowPainter(this.color, this.orientation, this.fromCoord, this.toCoord); + _ArrowPainter( + this.color, this.orientation, this.fromCoord, this.toCoord, this.scale); final Color color; final Side orientation; final Coord fromCoord; final Coord toCoord; + final double scale; @override void paint(Canvas canvas, Size size) { final squareSize = size.width / 8; - final lineWidth = squareSize / 4; + final lineWidth = scale * squareSize / 4; final paint = Paint() ..strokeWidth = lineWidth ..color = color @@ -87,7 +91,7 @@ class _ArrowPainter extends CustomPainter { math.atan2(toOffset.dy - fromOffset.dy, toOffset.dx - fromOffset.dx); final fromMarginOffset = Offset(margin * math.cos(angle), margin * math.sin(angle)); - final arrowSize = squareSize * 0.48; + final arrowSize = scale * squareSize * 0.48; const arrowAngle = math.pi / 5; final from = fromOffset + shift + fromMarginOffset;