diff --git a/lib/painter.dart b/lib/painter.dart index 261f66b..12d8a00 100644 --- a/lib/painter.dart +++ b/lib/painter.dart @@ -198,6 +198,7 @@ class PainterController extends ChangeNotifier { Color _drawColor = new Color.fromARGB(255, 0, 0, 0); Color _backgroundColor = new Color.fromARGB(255, 255, 255, 255); bool _eraseMode = false; + bool _rounded = false; double _thickness = 1.0; PictureDetails? _cached; @@ -221,6 +222,15 @@ class PainterController extends ChangeNotifier { _updatePaint(); } + /// Whether line caps and joins will be rounded. + bool get rounded => _rounded; + + /// If set to true, line caps and joins will be rounded. + set rounded(bool enabled) { + _rounded = enabled; + _updatePaint(); + } + /// Retrieves the current draw color. Color get drawColor => _drawColor; @@ -259,6 +269,10 @@ class PainterController extends ChangeNotifier { } paint.style = PaintingStyle.stroke; paint.strokeWidth = thickness; + if (_rounded) { + paint.strokeCap = StrokeCap.round; + paint.strokeJoin = StrokeJoin.round; + } _pathHistory.currentPaint = paint; _pathHistory.setBackgroundColor(backgroundColor); notifyListeners();