d4_color 1.0.0 copy "d4_color: ^1.0.0" to clipboard
d4_color: ^1.0.0 copied to clipboard

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.

Dart CI pub package package publisher

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.

This package provides representations for various color spaces, allowing specification, conversion and manipulation. (Also see d3_interpolate for color interpolation.)

For example, take the color named “steelblue”:

final c = Color.parse("steelblue"); // {r: 70, g: 130, b: 180, opacity: 1}

Let’s try converting it to HSL:

final c = Hsl.from("steelblue"); // {h: 207.27…, s: 0.44, l: 0.4902…, opacity: 1}

Now rotate the hue by 90°, bump up the saturation, and format as a string for CSS:

c.h += 90;
c.s += 0.2;
c.toString(); // rgb(198, 45, 205)

To fade the color slightly:

c.opacity = 0.8;
c.toString(); // rgba(198, 45, 205, 0.8)

In addition to the ubiquitous and machine-friendly RGB and HSL color space, d4_color supports color spaces that are designed for humans:

  • CIELAB (a.k.a. “Lab”)
  • CIELChab (a.k.a. “LCh” or “HCL”)
  • Dave Green’s Cubehelix

Cubehelix features monotonic lightness, while CIELAB and its polar form CIELChab are perceptually uniform. export 'src/d4_color.dart';

0
likes
130
pub points
18%
popularity

Publisher

verified publisherluizbarboza.com

Color spaces! RGB, HSL, Cubehelix, CIELAB, and more.

Repository (GitHub)
View/report issues

Documentation

API reference

License

ISC (LICENSE)

More

Packages that depend on d4_color