setalpha 0.9.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

setalpha #

A convenience package for setting and accessing web colors, adjusting the alpha levels of given colors and mixing new colors.

Usage #

A simple usage example:

import 'package:setalpha/setalpha.dart';

void main() {
  // Get cornflowerblue with an alpha value of 0.3...
  print(setAlpha(Color.cornflowerBlue, 0.3));
  // #6495ED4D

  // Also works for other hex and hsl expressions...
  print(setAlpha("#6495ED", 0.5));
  // #6495ED80

  print(setAlpha("hsl(218.54deg, 79%, 66%)", 0.5));
  // #6495ED80

  // Which web color is nearest cornflourblue in RGB-space?
  print(colorsNearest(Color.cornflowerBlue, 2).last);
  // mediumslateblue

  // Let's mix 3 parts cornflowerblue with 2 parts maroon...
  print(colorMix([Color.cornflowerBlue, Color.maroon], [3, 2]));
  // #6F598EFF
}

Demos #

A little app that demonstrates color manipulation, component data, finding similar colors and setting alpha levels using setalpha.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.9.3 #

  • Small additions and amendments to the ColorProperties class.

  • Fixed a bug in the interpretation of hsla expressions.

  • The colorsNearest function has been split into colorsNearestRGB and colorsNearestHSL that respectively return the nearest colors in RGB-space and HSL-space.

  • Added a convenience class Crayon that provides access to the crayon colors in the html color picker.

0.9.2 #

Dart pub issues (?)

0.9.1 #

  • Fixed several bugs that were introduced in the previous version.
  • Changed colorNearestRGB to a more generic and useful colorsNearest, which returns a list of colors in order of increasing distance. (Breaking change.)
  • Cleaned up the code: a lot more readable now.

0.9.0 #

  • Marked as ready for Dart 2.
  • Removed methods from abstract class Color: free-standing functions setAlpha, colorMix and colorNearestRGB are more convenient. (This is a breaking change.)
  • Output of setAlpha now an 8 digit hex value, matching the output of colorMix.
  • Added an abstract ColorProperty class that provides access to various qualities of an input color such as hue, saturation and lightness.

0.8.0 #

Added the function Color.mix, which allows us to mix a list of colors.

0.7.0 #

Added the function Color.nearest, which returns the css color nearest in rgb space to input rgb values.

0.6.0 #

Now also supports hsl expressions as input to function setAlpha.

0.5.0 #

  • Set the alpha level of CSS colors.
  • Supports color name, hex values, rgb (and rgba) expressions as input to the function setAlpha.

example/example.dart

import 'package:setalpha/setalpha.dart';

void main() {
  // Get cornflowerblue with an alpha value of 0.3...
  print(setAlpha(Color.cornflowerBlue, 0.3));
  // #6495ED4D

  // Also works for other hex and hsl expressions...
  print(setAlpha("#6495ED", 0.5));
  // #6495ED80

  print(setAlpha("hsl(218.54deg, 79%, 66%)", 0.5));
  // #6495ED80

  // Which web color is nearest cornflourblue in RGB-space?
  print(colorsNearestRGB(Color.cornflowerBlue, 2).last);
  // mediumslateblue

  // Let's mix 3 parts cornflowerblue with 2 parts maroon...
  print(colorMix([Color.cornflowerBlue, Color.maroon], [3, 2]));
  // #6F598EFF
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  setalpha: ^0.9.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:setalpha/setalpha.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:setalpha/setalpha.dart.

Health suggestions

Fix lib/src/color-mix.dart. (-1 points)

Analysis of lib/src/color-mix.dart reported 2 hints:

line 11 col 26: Use = to separate a named parameter from its default value.

line 13 col 5: DO use curly braces for all flow control structures.

Fix lib/src/color-property.dart. (-1 points)

Analysis of lib/src/color-property.dart reported 2 hints:

line 109 col 7: DO use curly braces for all flow control structures.

line 112 col 7: DO use curly braces for all flow control structures.

Fix lib/src/helpers.dart. (-0.50 points)

Analysis of lib/src/helpers.dart reported 1 hint:

line 10 col 5: DO use curly braces for all flow control structures.

Fix lib/src/set-alpha.dart. (-0.50 points)

Analysis of lib/src/set-alpha.dart reported 1 hint:

line 43 col 7: DO use curly braces for all flow control structures.

Maintenance suggestions

Package is getting outdated. (-20.27 points)

The package was last published 62 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.3 <3.0.0