Hi,

I played with colors and found out, that arithmetical operations with
colors are completely broken.

https://pharo.fogbugz.com/f/cases/15188/Color-ariphmetical-operations-are-broken

Result is not a valid Color - just garbage. It happens because alpha is not
being initialized and stays nil. It seems that operation were implemented
before alpha support was added. So I propose the following solution:

Color red - Color red = Color transparent

(Color white alpha: 1) -  (Color white alpha: 0.5) = (Color white alpha:
> 0.5)

R,G,B are subtracted as before. Alpha channels are subtracted too.

Color red + Color blue = Color magenta

Color red + Color transparent = Color red

(Color white alpha: 0.5) + (Color white alpha: 0.5) = (Color white alpha: 1)
>

 R,G,B are added as before. Alpha channels are added too.

Multiplication and division by number doesn't change alpha channel.

Cheers,
Alex

Reply via email to