color 2.1.1 copy "color: ^2.1.1" to clipboard
color: ^2.1.1 copied to clipboard

outdated

A simple Dart package exposing a Color class which can be used to create, convert, alter, and compare colors.

example/example.dart

import 'dart:html';
import 'package:color/color.dart';

Element body = querySelector('body');

main() {
  addGrid('Normal');
  addGrid('Sepia', ColorFilter.sepia);
  addGrid('Greyscale', ColorFilter.greyscale);
  addGrid('Inverted', ColorFilter.invert);
  addGrid('Lightened (20%)', ColorFilter.lighten, [.2]);
  addGrid('Darkened (20%)', ColorFilter.darken, [.2]);
}

addGrid(String name, [ColorFilter filter, List filterArgs = const []]) {
  body.appendText(name);
  Element grid = new Element.div()..classes.add('grid');
  body.append(grid);
  num step = 15.9375;
  for (num l = 0; l <= 100; l += step * 100 / 255) {
    Element block = new Element.div()..classes.add('block');
    grid.append(block);
    for (num a = -128; a <= 127; a += step) {
      for (num b = -128; b <= 127; b += step) {
        CielabColor color = new CielabColor(l, a, b);
        if (filter != null) {
          color = filter(color, filterArgs);
        }
        block.append(new Element.div()
          ..classes.add('color-block')
          ..style.background = color.toRgbColor().toCssString());
      }
    }
  }
}
32
likes
25
pub points
89%
popularity

Publisher

verified publishermikefenwick.com

A simple Dart package exposing a Color class which can be used to create, convert, alter, and compare colors.

Repository
View/report issues

License

MIT (license)

More

Packages that depend on color