All the code so far is in select.rb
. I set up a few helper functions at
the top of the file to get color components in floating point for the
hue calculations. The hue calculation itself is ripped straight from
Wikipedia HSL and HSV,
implemented in pure Ruby. I also took advantage of ChunkyPNG's
already-implemented grayscale conversion (after rolling my own first,
then realizing my mistake).
The commands used to generate all the versions are:
./select.rb 20 65 input.png yellow.png
./select.rb 0 18 input.png red.png
./select.rb 65 90 input.png green.png
./select.rb 185 215 input.png blue.png
./select.rb 235 245 input.png violet.png
where the command line syntax is:
select.rb <lower hue limit, 0-360.0> <upper hue limit, 0-360.0> <input file> <output file>
Since I'm not a GUI expert, I haven't wrapped this up with its own color picker - I used the ColorSync Utility built-in to my MacBook to estimate Hue value ranges for the different crayons.