Solving the colour scheme issues properly

Olaf Schmidt ojschmidt at kde.org
Fri Jul 6 18:41:02 BST 2007


Hi!

KColorScheme and the new tint function has received a lot of positive feedback 
from people here at aKademy.

People have only been very confused about complicated way to get a coloured 
background, so we should really add a convenience function for this to 
KColorScheme and improve documentation.

I have now also tested the tint algorithm.

[ Matthew Woehlke, Do., 5. Jul. 2007 ]
> Yes, mentioned in the thread on kde-usability, I'm guessing you missed
> it somehow? http://permalink.gmane.org/gmane.comp.kde.usability/15902

Thanks for the link. I am not subscribed to kde-usability - that's why I 
missed it.

> (Of course you'll now have to peer back in svn's history for the old
> algorithm; look at the revisions of testtint/main.cpp, it's only one or
> two back, but note that I think you need to copy it due to a BIC/SIC
> that (IIRC) happened since.)

I decided to instead port your algorithm to PHP and include it in 
http://accessibility.kde.org/oxygen.php?color=white as Tint 1.

I have colour-coded the tint amount on that page:
white means "enough contrast to light text" (i.e. colours above 0.65 luma),
black means "enough contrast to dark text" (i.e. colours below 0.07 luma),
and red means "not enough contrast".

I picked the 0.65 and 0.07 luma values because they have enough contrast with 
each other and include many different light and dark colours.

With white as base colour, your algorithm returns an invisible yellow tint 
for "amount" < 0.7. At the same time, the contrast is too small for the tint 
colours blue and red with "amount" > 0.4. Even worse is the contrast for 
other base colours:
http://accessibility.kde.org/oxygen.php?color=pink1
http://accessibility.kde.org/oxygen.php?color=skyblue5
http://accessibility.kde.org/oxygen.php?color=black

As a suggested solution, I experimented with a new algorithm (Tint2) that
a) returns colours with enough saturation to see the tint, and
b) always returns colours with enough contrast.

The formula is in pseudo-code:

    if (luma(base) < 0.07 && luma(tint) >= 0.07)
        temp_luma = 0.07;
    else if (luma(base) > 0.65 && luma(tint) <= 0.65)
        temp_luma = 0.65;
    else
        temp_luma = luma(tint);

    new_hue = tint(hue);
    new_luma = mix (luma(base), temp_luma, amount);
    new_saturation = mix (saturation(base), saturation(tint), amount);

The formula suggested by me would default to 1.0 (full tint);
0.0 is the untinted colour as in your algorithm.

If artists want to increase the tint even stronger (e.g. for decorations), 
they could use:
mix (tint (basecolor, tintcolor), tintcolor, mixamount)

Olaf




More information about the kde-core-devel mailing list