Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: packages/charted/lib/core/utils/color.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/charted/lib/core/utils/bidi_formatter.dart ('k') | packages/charted/lib/core/utils/lists.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/charted/lib/core/utils/color.dart
diff --git a/packages/charted/lib/core/utils/color.dart b/packages/charted/lib/core/utils/color.dart
index bac12ec22f63e80abb1d0897000e70f3f756921e..5912a5ea93821d366b4b00282d43b2374bb85844 100644
--- a/packages/charted/lib/core/utils/color.dart
+++ b/packages/charted/lib/core/utils/color.dart
@@ -17,9 +17,9 @@ class Color {
int _b = 0;
// Internal representation of HSL
- int _h = 0; // 0 <= _h <= 360
- int _s = 0; // 0 <= _s <= 100
- int _l = 0; // 0 <= _l <= 100
+ int _h = 0; // 0 <= _h <= 360
+ int _s = 0; // 0 <= _s <= 100
+ int _l = 0; // 0 <= _l <= 100
// Alpha value for this color
double _a = 0.0;
@@ -33,33 +33,33 @@ class Color {
/// Create an instance using a string representing color in RGB color space.
/// The input string, [value], can be one of the following formats:
- ///
+ ///
/// #RGB
/// #RRGGBB
- ///
+ ///
/// rgb(R, G, B)
/// rgba(R, G, B, A)
- ///
+ ///
/// R, G and B represent intensities of Red, Green and Blue channels and A
/// represents the alpha channel (transparency)
- ///
+ ///
/// When using these formats:
/// 0 <= R,G,B <= 255
/// 0 <= A <= 1.0
factory Color.fromRgbString(String value) =>
- isHexColorString(value) ? _fromHexString(value) : _fromRgbString(value);
-
+ isHexColorString(value) ? _fromHexString(value) : _fromRgbString(value);
+
/// Create an instance from HSL colors.
Color.fromHsla(this._h, this._s, this._l, this._a) : _hasHslColors = true;
/// Create an instance using a string representing color in HSL color space.
/// The input string, [value], can be in one of the following formats:
- ///
+ ///
/// hsl(H, S%, L%)
/// hsla(H, S%, L%, A)
- ///
+ ///
/// H, S and L represent Hue, Saturation and Luminosity respectively.
- ///
+ ///
/// When using these formats:
/// 0 <= H <= 360
/// 0 <= S,L <= 100
@@ -249,12 +249,12 @@ class Color {
/// Tests if [str] is a color represented by hsl() or hsla()
static bool isHslColorString(String str) => hslaColorRegExp.hasMatch(str);
-
+
/// Create an instance using the passed RGB string.
static Color _fromRgbString(String value) {
- int pos =
- (value.startsWith('rgb(') || value.startsWith('RGB(')) ? 4 :
- (value.startsWith('rgba(') || value.startsWith('RGBA(')) ? 5 : 0;
+ int pos = (value.startsWith('rgb(') || value.startsWith('RGB('))
+ ? 4
+ : (value.startsWith('rgba(') || value.startsWith('RGBA(')) ? 5 : 0;
if (pos != 0) {
final params = value.substring(pos, value.length - 1).split(',');
int r = int.parse(params[0]),
@@ -278,10 +278,9 @@ class Color {
if (hex.length == 3) {
for (final char in hex) {
final val = int.parse(char, radix: 16);
- rgb = (rgb * 16 + val ) * 16 + val;
+ rgb = (rgb * 16 + val) * 16 + val;
}
- }
- else if (hex.length == 6){
+ } else if (hex.length == 6) {
rgb = int.parse(hex, radix: 16);
}
@@ -291,9 +290,9 @@ class Color {
/// Create an instance using the passed HSL color string.
static Color _fromHslString(String value) {
- int pos =
- (value.startsWith('hsl(') || value.startsWith('HSL(')) ? 4 :
- (value.startsWith('hsla(') || value.startsWith('HSLA(')) ? 5 : 0;
+ int pos = (value.startsWith('hsl(') || value.startsWith('HSL('))
+ ? 4
+ : (value.startsWith('hsla(') || value.startsWith('HSLA(')) ? 5 : 0;
if (pos != 0) {
final params = value.substring(pos, value.length - 1).split(',');
int h = int.parse(params[0]),
« no previous file with comments | « packages/charted/lib/core/utils/bidi_formatter.dart ('k') | packages/charted/lib/core/utils/lists.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698