hooglth.blogg.se

Random color generator
Random color generator











random color generator
  1. #Random color generator update
  2. #Random color generator code

I added a helper function GetColorDistanceCIELab in ColorSpaceHelper class.I added Distance calculation in CIELab.cs.I changed Color class used from WinForm (System.Drawing) to WPF ().In fact, it was so good that I kept 99.9% of it and mainly just added 2 others classes (plus a Form to test).

#Random color generator code

I started from the excellent code found here on code project from Guillaume Leparmentier: Although, I haven’t seen a difference, the latest should give better results.

#Random color generator update

But Rob2412 (Thanks a lot Rob) give me the algorithm of CieLab2000 ( ) then I implemented it, tested it, and decided to update my code. This initial "Tips and tricks" was written with CieLab1997 algorithm. The color appears to me to have a greater distance between them. I decided to try to work with CieLab color distance and saw an improvement. Obtained results were sometimes with colors appearing to be too close to my eye. I thought HSL would be better and go with it.

random color generator

An additional nice feature would be to start generate color with very high distance between them and reduce the distance while color quantity increase (in order to introduce new ones).Īfter reading some article/code (like: ), I realized that it would be probably more easier/effective to work with HSB or HSL. Also, I needed to be able to add myself some color to reject. I found many random generators but they didn’t keep tracks of already used colors and do not ensure to generate color far from used ones. I searched on the web for an already existing solution and I haven’t found any.

  • Be able to add a distance factor to any inital colors to reject in order to stay very far from them.
  • Each new color should be easily distinguishable from any previous one.
  • I wanted to be able to put some weight to some color to ensure to stay away from them (like the background color). The initial application was a plot color attribution for a graphic control. I wanted to create a random color generator. Thanks to Member10716758 which I suspect it is Tompazourek to point me out this :-). Update : Please check the following link before reading further beause it is newer and appears to be a lot better than what I have made:













    Random color generator