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
19 changes: 12 additions & 7 deletions lib/tinycolor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down Expand Up @@ -143,12 +146,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);
}

Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down