mettli / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

Add += and -= operator for Color #71

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The summary says it all.

Original issue reported on code.google.com by olof.nae...@gmail.com on 10 Sep 2008 at 2:17

GoogleCodeExporter commented 9 years ago
What is the rationale behind this enhancement? What does it mean to add two 
colors?
Are they going to prevent overflow of the red, green and blue values? If so, 
then I
still can't calculate the average of color A and B using (A + B) / 2.

Original comment by b.lindeijer on 10 Sep 2008 at 2:23

GoogleCodeExporter commented 9 years ago
Adding two colours simply means adding them (the components are added), and it 
will 
prevent overflow but that's it. The result will always have an alpha channel 
with 
value 255. We already have the + and - operator and we have had them from the 
initial 
version of Guichan, so I thought why not add += and -= as well.

I realise these functions aren't very useful when it comes to colourisation, 
but 
that's not present in Guichan at the moment. The functions are used to darken 
and 
lighten colours when drawing borders and stuff, a stupid but simple approach. 
If 
colourisation were to be present we should probably use another intermediate 
colour 
representation, like HSV.

Original comment by olof.nae...@gmail.com on 10 Sep 2008 at 2:48

GoogleCodeExporter commented 9 years ago
Hmm, both Qt and Java have Color.darker Color.lighter for those purposes. And 
true,
at least I know for sure that QColor::lighter uses the value from HSV to make 
the
color lighter. I think methods like that are more understandable than operator 
overloads.

Original comment by b.lindeijer on 10 Sep 2008 at 3:35