Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions lib/src/colorpicker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

library hsv_picker;

import 'dart:math';

import 'package:flutter/material.dart';
import 'palette.dart';
import 'utils.dart';
Expand Down Expand Up @@ -697,11 +699,11 @@ class _HueRingPickerState extends State<HueRingPicker> {
ClipRRect(
borderRadius: widget.pickerAreaBorderRadius,
child: Padding(
padding: const EdgeInsets.all(15),
padding: const EdgeInsets.all(5),
child: Stack(alignment: AlignmentDirectional.center, children: <Widget>[
SizedBox(
width: widget.colorPickerHeight,
height: widget.colorPickerHeight,
width: widget.colorPickerHeight + widget.hueRingStrokeWidth,
height: widget.colorPickerHeight + widget.hueRingStrokeWidth,
child: ColorPickerHueRing(
currentHsvColor,
onColorChanging,
Expand All @@ -710,8 +712,8 @@ class _HueRingPickerState extends State<HueRingPicker> {
),
),
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),
)
]),
Expand Down Expand Up @@ -770,16 +772,16 @@ class _HueRingPickerState extends State<HueRingPicker> {
ClipRRect(
borderRadius: widget.pickerAreaBorderRadius,
child: Padding(
padding: const EdgeInsets.all(15),
padding: const EdgeInsets.all(5),
child: Stack(alignment: AlignmentDirectional.topCenter, children: <Widget>[
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(
Expand Down
17 changes: 13 additions & 4 deletions lib/src/palette.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Color> colors = [
const HSVColor.fromAHSV(1.0, 360.0, 1.0, 1.0).toColor(),
Expand All @@ -550,18 +550,27 @@ 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,
);
if (displayThumbColor) {
canvas.drawCircle(
offset,
size.height * 0.03,
strokeWidth / 2 - strokeWidth * 0.1,
Paint()
..color = hsvColor.toColor()
..style = PaintingStyle.fill,
Expand Down