Page 1 of 1
Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 12:13 pm
by Jasoco
Just curious. I notice that when you setColor with a value larger than 255 it wraps it around. So 256 becomes 0. So setColor(256,255,255) would end up being cyan instead of white. It also seems to do it in the opposite direction where negative numbers are wrapped. So basically any values sent to setColor are val % 256 - 1 or something like that. Is there a technical reason for this? I would think it would simply cap the value to 255 no matter how high it goes. Same with the lower bounds. If something lower than 0 is passed it would clip to 0.
Was just curious as to why this behavior was chosen.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 12:45 pm
by bartbes
It's an overflow, the values are stored in single bytes.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 4:08 pm
by tentus
Should we consider this a permanent behavior then? A feature, if you will?
I ask because I can think of some visual effects code that could be simplified by capitalizing on this.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 8:05 pm
by Robin
I think it would be wise to let the behaviour be undefined, until version 1.0. Versions in between could experiment which of wrapping, clamping, generating an error or something else is most desirable.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 8:19 pm
by TechnoCat
Robin wrote:I think it would be wise to let the behaviour be undefined, until version 1.0. Versions in between could experiment which of wrapping, clamping, generating an error or something else is most desirable.
Unless there is a roadmap somewhere I'm unaware of, this 1.0 stable thing is nonsense.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 8:27 pm
by Robin
Oh, there is a roadmap. It's all here, in my head.
Re: Why does setColor wrap values over 255?
Posted: Sun Mar 18, 2012 8:42 pm
by TechnoCat
Robin wrote:Oh, there is a roadmap. It's all here, in my head.
Re: Why does setColor wrap values over 255?
Posted: Mon Mar 19, 2012 7:51 am
by Jasoco
I can totally see a 0.10.0 sometime within the next couple years. Followed by a 0.11.0. We'll never make it to 1.0, but that's okay. As long as each release is stable and brings a lot of new stuff to the table. lolol.. I rhymed.