gcode-mirror / phamlp

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

Processing of color components numeric overflowing #52

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Current solution (methods SassColour.getBlue, SassColour.getRed, 
SassColour.getGreen)

$component = round(abs($this->blue));
return ($component > 255 ? $component % 255 : $component);

i.e. it returns modulo 255 of absolute value of color component. This is not 
very obviously and predictable.

If I do #F0F0F0 + #200000 I get smth like #10F0F0 but more expected value 
(#FFF0F0) can be retrieved with the following code:

return max(0, min(255, round($this->blue)); 

http://en.wikipedia.org/wiki/Color_mixing#Additive_Mixing
http://en.wikipedia.org/wiki/Color_theory

Original issue reported on code.google.com by michael....@gmail.com on 20 Oct 2010 at 2:22

Attachments:

GoogleCodeExporter commented 9 years ago
This patch has been applied in https://github.com/MarcWeber/phamlp

Original comment by gabriel%...@gtempaccount.com on 6 Mar 2011 at 5:40