Skip to main content

flutter_kurkle_color_port 0.2.0 copy "flutter_kurkle_color_port: ^0.2.0" to clipboard
flutter_kurkle_color_port: ^0.2.0 copied to clipboard

A native Dart port of @kurkle/color 0.3.2, the color library of Chart.js: parse hex, rgb, hsl, hwb and hsv colors and CSS color names, mix and change colors.

A native Dart port of @kurkle/color 0.3.2 for Flutter.

Overview #

Fast and small CSS color parsing and manipulation library.

Usage #

The methods of the upstream Color class are the extension KurkleColor on the Flutter Color. Each method returns a new color.

import 'dart:ui';

import 'package:flutter_kurkle_color_port/flutter_kurkle_color_port.dart';

void main() {
  const blue = Color(0xFF3366CC);
  print(blue.lighten(0.2).rotate(30).withAlphaRatio(0.5).rgbString()); // rgba(112, 92, 214, 0.5)
  print(const Color(0xFFFF0000).mix(const Color(0xFF0000FF), 0.25).hexString()); // #4000BF
  print(hexString(nameParse('steelblue'))); // #4682B4
}

The parse functions hexParse, nameParse, rgbParse and hueParse read the CSS text forms below into an RGBA. KurkleColor.fromRgbaBytes makes a Flutter Color of it.

Parsing #

Supported formats:

  • named
blue
transparent
  • hex
#aaa
#bbba
#1A2b3c
#f1f2f388
  • rgb(a)
rgb(255, 255, 255)
rgb(255, 0, 0, 0.5)
rgb(50%, 50%, 50%, 50%)
rgb(0 0 100% / 80%)
rgba(200, 20, 233, 0.2)
rgba(200, 20, 233, 2e-1)
  • hsl(a)
hsl(240deg, 100%, 50.5%)
hsl(0deg 100% 50%)
hsla(12, 10%, 50%, .3)
hsla(-1.2, 10.2%, 50.9%, 0.4)
  • hwb
hwb(240, 100%, 50.5%)
hwb(244, 100%, 100%, 0.6)
  • hsv
hsv(240, 100%, 50.5%)
hsv(244, 100%, 100%, 0.6)
0
likes
160
points
422
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A native Dart port of @kurkle/color 0.3.2, the color library of Chart.js: parse hex, rgb, hsl, hwb and hsv colors and CSS color names, mix and change colors.

Repository (GitHub)
View/report issues
Contributing

Topics

#color #css #chartjs

License

MIT (license)

Dependencies

flutter

More

Packages that depend on flutter_kurkle_color_port