From 3a513f9357149bfedf9b4fc7cbf36f106a99d566 Mon Sep 17 00:00:00 2001 From: Salman S Date: Thu, 24 Sep 2020 09:35:27 +0700 Subject: [PATCH 1/2] fix function mix --- lib/tinycolor.dart | 12 +++++++----- pubspec.lock | 2 +- pubspec.yaml | 5 +++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/tinycolor.dart b/lib/tinycolor.dart index 06e429d..263ebaf 100644 --- a/lib/tinycolor.dart +++ b/lib/tinycolor.dart @@ -143,12 +143,14 @@ class TinyColor { } TinyColor mix({@required Color input, int amount = 50}) { - final int p = (amount / 100).round(); + final double p = (amount / 100); final color = Color.fromARGB( - (input.alpha - _color.alpha) * p + _color.alpha, - (input.red - _color.red) * p + _color.red, - (input.green - _color.green) * p + _color.green, - (input.blue - _color.blue) * p + _color.blue); + ((input.alpha - _color.alpha) * p).round() + _color.alpha, + ((input.red - _color.red) * p).round() + _color.red, + ((input.green - _color.green) * p).round() + _color.green, + ((input.blue - _color.blue) * p).round() + _color.blue, + ); + return TinyColor(color); } diff --git a/pubspec.lock b/pubspec.lock index 544bf47..7cfe175 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -68,7 +68,7 @@ packages: source: hosted version: "0.12.8" meta: - dependency: transitive + dependency: "direct main" description: name: meta url: "https://pub.dartlang.org" diff --git a/pubspec.yaml b/pubspec.yaml index 1bb06c5..14c9a97 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -8,10 +8,11 @@ environment: flutter: ">=1.12.0 <3.0.0" dependencies: - pigment: ^1.0.3 - meta: ^1.2.2 flutter: sdk: flutter + + pigment: ^1.0.3 + meta: ^1.1.8 dev_dependencies: flutter_test: From 7141bb99a37b506de5e51416bdbeaa08329b7573 Mon Sep 17 00:00:00 2001 From: Salman S Date: Thu, 24 Sep 2020 10:30:46 +0700 Subject: [PATCH 2/2] default alpha at fromRGB --- lib/tinycolor.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/tinycolor.dart b/lib/tinycolor.dart index 263ebaf..d5ef743 100644 --- a/lib/tinycolor.dart +++ b/lib/tinycolor.dart @@ -23,8 +23,11 @@ class TinyColor { Color.fromARGB(color.alpha, color.red, color.green, color.blue); } - factory TinyColor.fromRGB( - {@required int r, @required int g, @required int b, int a = 100}) { + factory TinyColor.fromRGB({ + // default alpha should be 255, not 100 + // since Color.fromARGB accept alpha range values 0-255, not 0-100 + @required int r, @required int g, @required int b, int a = 255, + }) { return TinyColor(Color.fromARGB(a, r, g, b)); }