What to do about KColor?

Andreas Pakulat apaku at gmx.de
Mon May 28 18:12:29 BST 2007


On 28.05.07 18:10:42, Thomas Zander wrote:
> On Monday 28 May 2007 16:37:37 Ingo Klöcker wrote:
> > > I expect people to adjust to the new concepts over the duration of
> > > the KDE4 lifetime and when they do, then it becomes weird when there
> > > are two conflicting ways to set the blending amount.
> >
> > Why conflicting? If I blend two colors with different alpha values a1
> > and a2 then I'd expect to get the blended color with alpha value
> > (a1+a2)/2 ( or (1-r) a1 + r a2 in the more general case ). Again,
> > that's what I as email application developer (and maybe also as
> > mathematician) would expect. I don't want to study color theory to
> > understand what a certain method I want to use actually does. No, I
> > want the method to do what I expect it to do. But I guess just as in
> > application usability you'll get ten different expectations if you ask
> > ten different people.
> 
> We are talking about slightly different things here :)
> 
> I agree with what you wrote above;  blending of 2 colors means take the 
> average (and that is exactly what the current one does).

It does? So If I do just

blendColor(Qt::white, Qt:red) 

I end up with a light red? (I didn't test yet, kdelibs is currently
building). I'm not a graphics expert but as far as I can see the
blendColors function just paints 2 rects using the two provided colors
on top of each other. So to get actual blending I need to set an alpha
value on the 2nd color. Or do I have to provide another composition mode
to get that result? Neither of these two is something that an app
developer should have to think about, IMHO. 

> The request you wrote in the previous email is to change the blend method 
> to include a double on how much blending is done.
> So, instead of using the exact difference between the two you are able to 
> state how strong the second color is applied to the first in returning 
> the result.
> And that makes sense in old colors, sure.  Where is starts to get a bit 
> weird is if you have a color A and a color B where color B has an alpha 
> of 50% and you call the blendColor with an additional 
> parameter 'strength' that you also set to 50%.
> The question that different people will probably answer differently is how 
> strong the second color will have to be applied. Is it 50%? Or is it 25% 
> (50% of the 50% that the color is already transparent). Or even something 
> different based on color theory which is not perfectly linear...

So the problem is if a given color has an alpha value set already right?
But that doesn't change with the above unless I misunderstand the
algorithm that is in kdelibs now. Because as far as I can see I still
need to set an alpha value, which would override the current alpha value
of the color. So the only solution to this (afaics) is to check wether
color B already has an alpha value set and then try to decide wether to
change that in a meaningful way or to leave it as is and just mix color
A with color B directly. I don't see why this would have to be rewritten
in every class that uses blendColor and how an app developer with no
graphics background should decide what exactly to do.

> > Whoever adds code to our core libraries should be aware of the fact
> > that this functionality will be used by people who are not necessarily
> > experts in the domain of this functionality. Functionality that does
> > require more than a slight understanding of the matter and some common
> > sense does IMO not belong into our core libraries but into some special
> > purpose libraries, like say Pigment. So please keep the color related
> > stuff in kdelibs dead simple and easily understandable for idiots like
> > me. Thanks!
> 
> Fully agreed, and I was under the impression that this new method that was 
> committed this morning does exactly that.
> It blends 2 colors. Nothing more, nothing less.

As I said above, just doing blendColor(c1,c2) doesn't give you anything
but c2 (unless c2 already has an alpha set). Thats the main point,
calling that function what I want to end up is a mix of those two
colors, not the original c2, without any extra work.

Andreas

-- 
Many changes of mind and mood; do not hesitate too long.




More information about the kde-core-devel mailing list