Skip to content

Commit

Permalink
Merge pull request #33 from TinyCommunity/release-preparation
Browse files Browse the repository at this point in the history
Release preparation
  • Loading branch information
WieFel authored Jul 28, 2021
2 parents b605013 + 95bf3bd commit 1f060e3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## [2.0.0] - TBD
## [2.0.0] - 2021-07-28

### Added
* `.toHex8()` at [PR #17](https://github.com/TinyCommunity/tinycolor2/pull/17)
Expand Down
File renamed without changes.
24 changes: 15 additions & 9 deletions lib/src/tinycolor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,25 @@ class TinyColor {
final color = Color.fromARGB(
_color.alpha,
math.max(
0, math.min(
255, _color.red - (255 * -(amount / 100)).round(),
),
0,
math.min(
255,
_color.red - (255 * -(amount / 100)).round(),
),
),
math.max(
0, math.min(
255, _color.green - (255 * -(amount / 100)).round(),
),
0,
math.min(
255,
_color.green - (255 * -(amount / 100)).round(),
),
),
math.max(
0, math.min(
255, _color.blue - (255 * -(amount / 100)).round(),
),
0,
math.min(
255,
_color.blue - (255 * -(amount / 100)).round(),
),
),
);
return TinyColor(color);
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version: 2.0.0
homepage: https://github.com/TinyCommunity/tinycolor2

environment:
sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.12.0"

dependencies:
flutter:
Expand Down
7 changes: 4 additions & 3 deletions test/tinycolor_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void main() {
test(
"setAlpha updates alpha value of color",
() {
TinyColor color = TinyColor(Color(0xFFFFFFFF));
final TinyColor color = TinyColor(const Color(0xFFFFFFFF));
color.setAlpha(0x00);
expect(color.color.alpha, 0x00);
},
Expand All @@ -16,10 +16,11 @@ void main() {
test(
"setOpacity updates opacity value of color",
() {
TinyColor color = TinyColor(Color(0xFFFFFFFF).withOpacity(1.0));
final TinyColor color =
TinyColor(const Color(0xFFFFFFFF).withOpacity(1.0));
color.setOpacity(0.5);

// underlying dart implementation converts the opacity value to an
// underlying dart implementation converts the opacity value to an
// int, then back into a double. Thus some precision is loss.
expect(color.color.opacity, moreOrLessEquals(0.5, epsilon: 1e-2));
},
Expand Down

0 comments on commit 1f060e3

Please sign in to comment.