color_thief_flutter 0.1.0 copy "color_thief_flutter: ^0.1.0" to clipboard
color_thief_flutter: ^0.1.0 copied to clipboard

outdated

Grab the color palette from an image, the Flutter implementation of color-thief.

color_thief_flutter #

the Flutter implementation of color-thief, based on color-thief.

Usage #

import 'package:color_thief_flutter/color_thief_flutter.dart';
import 'package:color_thief_flutter/utils.dart';

// color_thief_flutter.dart

getColorFromImage(image).then((color) {
  print(color); // [R,G,B]
});

getColorFromUrl('url/to/image').then((color) {
  print(color); // [R,G,B]
});

getPaletteFromImage(image).then((palette) {
  print(palette); // [[R,G,B]]
});

getPaletteFromUrl(image).then((palette) {
  print(palette); // [[R,G,B]]
});

getImageFromUrl('url/to/image').then((image) {
  print(image); // Image
});

// utils.dart

final hsv = fromRGBtoHSV([90, 90, 90]);
print(hsv); // [0, 0, 35]

final rgb = fromHSVtoRGB([90, 90, 90]);
print(rgb); // [126, 230, 23]

color_thief_flutter.dart #

Main package of color_thief_flutter.

All these functions return null if the parameter is unqualified

getColorFromImage(Image image, [int quality = 10])

returns the base color from the largest cluster, represented as [R,G,B]

getColorFromUrl(String url, [int quality])

returns the base color from the largest cluster, represented as [R,G,B]

getPaletteFromImage(Image image, [int colorCount, int quality])

returns a list that contains the reduced color palette, represented as [[R,G,B]]

getPaletteFromUrl(String url, [int colorCount, int quality])

returns a list that contains the reduced color palette, represented as [[R,G,B]]

getImageFromUrl(String url)

returns the Image from url

parameters

  • image - Image.
  • url - Url to image.
  • colorCount - Between 2 and 256. The maximum number of colours allowed in the reduced palette.
  • quality - Between 1 and 10. There is a trade-off between quality and speed. The bigger the number, the faster the palette generation but the greater the likelihood that colors will be missed.

utils.dart #

Tools for format colors.

May cause loss of significance

fromRGBtoHSV(List

retruns HSVColor, represented as [H,S,V]

fromHSVtoRGB(List

retruns RGBColor, represented as [R,G,B]

parameters

  • R,G,B's range is [0,255]
  • H's range is [0,360]
  • S,V's range is [0,100]

License #

Licensed under the MIT License.

37
likes
40
pub points
36%
popularity

Publisher

unverified uploader

Grab the color palette from an image, the Flutter implementation of color-thief.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, quantize_dart

More

Packages that depend on color_thief_flutter