neocolor

Color definition, manipulation, conversion, and comparison in fluent Dart.

On pub.dev Code coverage Github action status Dartdocs Style guide

Purpose

Provides platform-agnostic (i.e. CLI, Flutter, Web) classes and conventions for defining (creating or parsing from popular formats), manipulating (changing elements like brightness, hue, saturation, etc), conversion (from/to popular formats), and comparison (sometimes called "distance") Color elements.

Usage

If you've used Flutter's Color class, you'll feel at home:

import 'package:neocolor/neocolor.dart';

void main() {
  const c1 = Color(0xFF42A5F5);
  const c2 = Color.fromARGB(0xFF, 0x42, 0xA5, 0xF5);
  print('$c1 == $c2: ${c1 == c2}');

  const c3 = Color.fromARGB(255, 66, 165, 245);
  const c4 = Color.fromRGBO(66, 165, 245, 1.0);
  print('$c3 == $c4: ${c3 == c4}');

  // NEW: Use HSB (sometimes called HSV) and HSL to create colors too!
  final c5 = Color.fromHSB(207, 73.1, 96.1);
  final c6 = Color.fromHSL(207, 89.9, 61.0);
  print('$c5 == $c6: ${c5 == c6}');
}

Contributing

This package welcomes new issues and pull requests.

Changes or requests that do not match the following criteria will be rejected:

  1. Common decency as described by the Contributor Covenant.
  2. Making this library brittle/extensible by other libraries.
  3. Adding platform-specific functionality.
  4. A somewhat arbitrary bar of "complexity", everything should be easy to use.

Inspiration

Packages already exist that tackle this problem, often in similar ways:

If one of these packages suits your needs better, use it instead!

Libraries

neocolor