Tweek Colours
I
find getting the right colour for an object by changing RGB values
is non-intuitive and slow. There are declared colours available in
various include files but, unless the colour you want is included and
you know its name, you are back to an anonymous RGB value . To over
come this I have written a macro that allows you to name a starting
colour something like what you want and then tweek it to make it a
slightly different shade.
The
macro takes four parameters: the name of the colour as a string, change
to hue, change of luminance and change of saturation.
For
example; Tweeked_Colour("SeaGreen", 20, -10, 0)
takes the
named colour SeaGreen, changes the hue by 20 degrees to make it a bit
bluer, reduces the saturation to make it a bit greyer and leaves the
luminance the same. The result can be seen in this figure:
The bottom line is the actual rgb vectors, from which, I find, is
not easy to deduce the colour.
The programme Find_Tweek_Colours.pov
generates an array of slightly differing colours, as shown below, and
instructions on how to use it.
The
center sphere is the original SeaGreen colour and the spheres
either side
in each sub-array
have a small change of saturation while the rows above and below
lighter and darker. The sub-arrays on either side have differences in
hue, shown in degrees.
The
RGB values are saved in a text file: Tweeked_Colours.txt in rows and columns coresponding to the above image
The macro Tweeked_Colour(name, dH, dS, dL) is in Tweek_Colours.inc
togther with:
- A library of starting colours with names as
strings and also as declared rgb vectors.
- A look-up table so that the rgb value of any of
these colours can be retrieved by the colour name as a string variable
- A means of displaying a selection of these colours
as a palette with names
- A means of saving the same palette as a text file
with array of rgb values with names
The library of colours contains:
In Tweek_Colours.inc
the procedure for converting from rgb space to HCL space and back uses
vector rotation. I found this worked better than the macros in
colors.inc
It works by rotating the rgb vector so that the rgb
colour cube has the black/white aligned with the z-axis and the red
axis in the x-z plane.
This means that the x-y plane is the Hue
plane and rotation around the z-axis gives a change of Hue. The length
of the vector proportioan to luminance and the angle of the vector with
the z-axis is proportional to the saturation.