Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
56d7d94
Update issue templates
calvintam236 Jun 24, 2021
f61116c
Update pubspec for this fork
calvintam236 Jun 24, 2021
f431be7
Update underlying color with setting alpha and opacity.
TNorbury Jun 24, 2021
2f13899
restructure as a library
TNorbury Jun 24, 2021
1997311
format code for pub points
TNorbury Jun 24, 2021
797606a
Fixes issues #2 and #10 in FooStudio/tinycolor
dsyrstad Jun 24, 2021
ee3ab47
Merge pull request #5 from dsyrstad/master
calvintam236 Jun 25, 2021
acf1be2
Merge remote-tracking branch 'upstream/master' into fix_set_alpha_opa…
TNorbury Jun 25, 2021
68d18fd
spelling
TNorbury Jun 25, 2021
1fc89ce
Create SECURITY.md
calvintam236 Jun 26, 2021
7ab3574
Update issue templates
calvintam236 Jun 26, 2021
ee0125f
Merge pull request #9 from TinyCommunity/hotfix/issues-template
calvintam236 Jun 26, 2021
2d25c26
Merge pull request #10 from TinyCommunity/hotfix/security-policy
calvintam236 Jun 26, 2021
3cf7078
Update changelog template
calvintam236 Jun 29, 2021
89c7b9d
Merge pull request #12 from TinyCommunity/hotfix/changelog
calvintam236 Jun 29, 2021
e33128c
Merge pull request #4 from TNorbury/fix_set_alpha_opacity
calvintam236 Jul 4, 2021
ab21b08
Use shorthand return, remove unnecessary this, add trailing commas
calvintam236 Jul 4, 2021
1bdf380
Use shorthand return, add trailing commas
calvintam236 Jul 4, 2021
82ae4c5
Use shorthand return, remove unnecessary import
calvintam236 Jul 4, 2021
817d188
Use shorthand return, add trailing commas, fix missing @required
calvintam236 Jul 4, 2021
76164cc
Use shorthand return
calvintam236 Jul 4, 2021
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
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information)**
- Package version [e.g. 22]
- Dart version [e.g. 2.12.0]
- Flutter version [e.g. 2.2.0]
- Target platform for Flutter [e.g. Android, iOS, web, etc.]

**Additional context**
Add any other context about the problem here (including error message, logs).
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/vulnerability-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Vulnerability report
about: Report any vulnerability you have found.
title: ''
labels: vulnerability
assignees: ''

---

**Describe the vulnerability**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information)**
- Package version [e.g. 22]
- Dart version [e.g. 2.12.0]
- Flutter version [e.g. 2.2.0]
- Target platform for Flutter [e.g. Android, iOS, web, etc.]

**Additional context**
Add any other context about the problem here (including error message, logs).
41 changes: 32 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
## [1.0.3]
* Added Color class extension method for direct usage
## [1.0.2]
* Fixed compatibility issues with dart 2.1 and pigment 1.0.3
## [1.0.1]
* Fixed HSLColor class name duplicate definition.
* Updated package description
## [1.0.0]
* Initial port of tinycolor2
# Changelog

## [2.0.0] - TBD

### Changed
* Forked as a community version `tinycolor2`

### Fixed
* #2, #6, #10 from upstream at [PR #5](https://github.com/TinyCommunity/tinycolor2/pull/5)

## [1.0.3] - 2020-08-27

### Added
* Color class extension method for direct usage

## [1.0.2] - 2018-08-17

### Fixed
* Compatibility issues with dart 2.1 and pigment 1.0.3

## [1.0.1] - 2018-08-04

### Fixed
* HSLColor class name duplicate definition

### Changed
* Package description

## [1.0.0] - 2018-08-04

### Added
* Initial port of tinycolor2
14 changes: 14 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Security Policy

## Supported Versions

The following versions are currently being supported with security updates.

| Version | Supported |
| ------- | ------------------ |
| 2.0.x | :white_check_mark: |
| < 2.0 | :x: |

## Reporting a Vulnerability

To report any security issues, please open an issue [here](https://github.com/TinyCommunity/tinycolor2/issues/new/choose).
12 changes: 0 additions & 12 deletions lib/hsl_color.dart

This file was deleted.

10 changes: 6 additions & 4 deletions lib/color_extension.dart → lib/src/color_extension.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'package:flutter/painting.dart';
import 'tinycolor.dart';

/// Extends the Color class to allow direct TinyColor manipulation nativly
/// Extends the Color class to allow direct TinyColor manipulation natively
extension TinyColorExtension on Color {
/// Converts standard Color to TinyColor object
TinyColor toTinyColor() => TinyColor(this);

HSVColor toHsv() => TinyColor(this).toHsv();

HslColor toHsl() => TinyColor(this).toHsl();

/// Lighten the color a given amount, from 0 to 100. Providing 100 will always return white.
Expand All @@ -26,7 +26,8 @@ extension TinyColorExtension on Color {
Color shade([int amount = 10]) => TinyColor(this).shade(amount).color;

/// Desaturate the color a given amount, from 0 to 100. Providing 100 will is the same as calling greyscale.
Color desaturate([int amount = 10]) => TinyColor(this).desaturate(amount).color;
Color desaturate([int amount = 10]) =>
TinyColor(this).desaturate(amount).color;

/// Saturate the color a given amount, from 0 to 100.
Color saturate([int amount = 10]) => TinyColor(this).saturate(amount).color;
Expand All @@ -53,5 +54,6 @@ extension TinyColorExtension on Color {
Color get compliment => TinyColor(this).complement().color;

/// Blends the color with another color a given amount, from 0 - 100, default 50.
Color mix(Color toColor, [int amount = 50]) => TinyColor(this).mix(input: toColor, amount: amount).color;
Color mix(Color toColor, [int amount = 50]) =>
TinyColor(this).mix(input: toColor, amount: amount).color;
}
35 changes: 19 additions & 16 deletions lib/conversion.dart → lib/src/conversion.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import 'package:meta/meta.dart';
import 'hsl_color.dart';
import 'util.dart';

HslColor rgbToHsl(
{@required double r, @required double g, @required double b}) {
HslColor rgbToHsl({
@required double r,
@required double g,
@required double b,
}) {
r = bound01(r, 255.0);
g = bound01(g, 255.0);
b = bound01(b, 255.0);
Expand Down Expand Up @@ -37,9 +40,7 @@ HslColor rgbToHsl(
return HslColor(h: h, s: s, l: l);
}

Color hslToColor(HslColor hsl) {
return hslToRgb(hsl);
}
Color hslToColor(HslColor hsl) => hslToRgb(hsl);

Color hslToRgb(HslColor hsl) {
double r;
Expand All @@ -59,21 +60,23 @@ Color hslToRgb(HslColor hsl) {
b = _hue2rgb(p, q, h - 1 / 3);
}
return Color.fromARGB(
hsl.a.round(), (r * 255).round(), (g * 255).round(), (b * 255).round());
hsl.a.round(),
(r * 255).round(),
(g * 255).round(),
(b * 255).round(),
);
}

HSVColor colorToHsv(Color color) {
return HSVColor.fromColor(color);
}
HSVColor colorToHsv(Color color) => HSVColor.fromColor(color);

HSVColor rgbToHsv(
{@required int r, @required int g, @required int b, @required int a}) {
return colorToHsv(Color.fromARGB(a, r, g, b));
}
HSVColor rgbToHsv({
@required int r,
@required int g,
@required int b,
@required int a,
}) => colorToHsv(Color.fromARGB(a, r, g, b));

Color hsvToColor(HSVColor hsv) {
return hsv.toColor();
}
Color hsvToColor(HSVColor hsv) => hsv.toColor();

double _hue2rgb(double p, double q, double t) {
if (t < 0) t += 1;
Expand Down
15 changes: 15 additions & 0 deletions lib/src/hsl_color.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class HslColor {
double h;
double s;
double l;
double a;

HslColor({
@required this.h,
@required this.s,
@required this.l,
this.a = 0.0,
});

String toString() => "HSL(h: $h, s: $s, l: $l, a: $a)";
}
Loading