diff --git a/lib/src/colorpicker.dart b/lib/src/colorpicker.dart index 26374ef..4809176 100644 --- a/lib/src/colorpicker.dart +++ b/lib/src/colorpicker.dart @@ -4,6 +4,8 @@ library hsv_picker; +import 'dart:math'; + import 'package:flutter/material.dart'; import 'palette.dart'; import 'utils.dart'; @@ -697,11 +699,11 @@ class _HueRingPickerState extends State { ClipRRect( borderRadius: widget.pickerAreaBorderRadius, child: Padding( - padding: const EdgeInsets.all(15), + padding: const EdgeInsets.all(5), child: Stack(alignment: AlignmentDirectional.center, children: [ SizedBox( - width: widget.colorPickerHeight, - height: widget.colorPickerHeight, + width: widget.colorPickerHeight + widget.hueRingStrokeWidth, + height: widget.colorPickerHeight + widget.hueRingStrokeWidth, child: ColorPickerHueRing( currentHsvColor, onColorChanging, @@ -710,8 +712,8 @@ class _HueRingPickerState extends State { ), ), SizedBox( - width: widget.colorPickerHeight / 1.6, - height: widget.colorPickerHeight / 1.6, + width: (widget.colorPickerHeight - widget.hueRingStrokeWidth) / 1.45, + height: (widget.colorPickerHeight - widget.hueRingStrokeWidth) / 1.45, child: ColorPickerArea(currentHsvColor, onColorChanging, PaletteType.hsv), ) ]), @@ -770,16 +772,16 @@ class _HueRingPickerState extends State { ClipRRect( borderRadius: widget.pickerAreaBorderRadius, child: Padding( - padding: const EdgeInsets.all(15), + padding: const EdgeInsets.all(5), child: Stack(alignment: AlignmentDirectional.topCenter, children: [ SizedBox( - width: widget.colorPickerHeight - widget.hueRingStrokeWidth * 2, - height: widget.colorPickerHeight - widget.hueRingStrokeWidth * 2, + width: widget.colorPickerHeight - widget.hueRingStrokeWidth, + height: widget.colorPickerHeight - widget.hueRingStrokeWidth, child: ColorPickerHueRing(currentHsvColor, onColorChanging, strokeWidth: widget.hueRingStrokeWidth), ), Column( children: [ - SizedBox(height: widget.colorPickerHeight / 8.5), + SizedBox(height: widget.colorPickerHeight / 8.5 + widget.hueRingStrokeWidth / 2), ColorIndicator(currentHsvColor), const SizedBox(height: 10), ColorPickerInput( diff --git a/lib/src/palette.dart b/lib/src/palette.dart index 81f34c4..63a92d5 100644 --- a/lib/src/palette.dart +++ b/lib/src/palette.dart @@ -526,7 +526,7 @@ class HueRingPainter extends CustomPainter { void paint(Canvas canvas, Size size) { Rect rect = Offset.zero & size; Offset center = Offset(size.width / 2, size.height / 2); - double radio = size.width <= size.height ? size.width / 2 : size.height / 2; + double radio = (size.width <= size.height ? size.width / 2 : size.height / 2) - strokeWidth / 2; final List colors = [ const HSVColor.fromAHSV(1.0, 360.0, 1.0, 1.0).toColor(), @@ -550,10 +550,19 @@ class HueRingPainter extends CustomPainter { center.dx + radio * cos((hsvColor.hue * pi / 180)), center.dy - radio * sin((hsvColor.hue * pi / 180)), ); - canvas.drawShadow(Path()..addOval(Rect.fromCircle(center: offset, radius: 12)), Colors.black, 3.0, true); + canvas.drawShadow( + Path() + ..addOval(Rect.fromCircle( + center: offset, + radius: strokeWidth / 2 + strokeWidth * 0.1, + )), + Colors.black, + 3.0, + true, + ); canvas.drawCircle( offset, - size.height * 0.04, + strokeWidth / 1.8, Paint() ..color = Colors.white ..style = PaintingStyle.fill, @@ -561,7 +570,7 @@ class HueRingPainter extends CustomPainter { if (displayThumbColor) { canvas.drawCircle( offset, - size.height * 0.03, + strokeWidth / 2 - strokeWidth * 0.1, Paint() ..color = hsvColor.toColor() ..style = PaintingStyle.fill,