Skip to content

akilasithum/ColorMine

 
 

Repository files navigation

ColorMine

MIT Licensed .Net library that makes converting between color spaces and comparing colors easy.

Color Conversions

You can convert between any supported color spaces via generic methods like so:

var myRgb = new Rgb { R = 149, G = 13, B = 12 }
var myCmy = myRgb.To<Cmy>();
var myXyz = new Xyz { X = .44, Y = .7, Z = .99 }
var myLab = myXyz.To<Lab>();
var myYxy = new Xyz { Y1 = .1124, X = .22, Y2 = .14 }
var myHsl = myYxy.To<Hsl>();

Online example at http://colormine.org/color-converter

Delta-E

Delta-E calculations take and compare colors in any of the supported formates.

double deltaE = myRgb.Compare(myCmy,new Cie1976Comparison());
double deltaE = myXyz.Compare(myLab,new CmcComparison(lightness: 2, chroma: 1));
double deltaE = myYxy.Compare(myHsl,new Cie94(Cie94Comparison.Application.GraphicArts));

Note: Delta-e calculations are quasimetric, the result of comparing color a to b isn't always equal to comparing color b to a...but it will probably be pretty close!


Currently Supported Color Spaces

  • CMY
  • CMYK
  • HSL
  • HSB
  • HSV
  • CIE L*AB
  • Hunter LAB
  • LCH
  • LUV
  • RGB
  • XYZ
  • YXY

Currently Supported Comparisons

  • CIE76
  • CMC l:c
  • CIE94

About

.Net library that makes working with colors easy!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published