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.
Why does setColor wrap values over 255?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Why does setColor wrap values over 255?
It's an overflow, the values are stored in single bytes.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Why does setColor wrap values over 255?
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.
I ask because I can think of some visual effects code that could be simplified by capitalizing on this.
Kurosuke needs beta testers
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Why does setColor wrap values over 255?
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.
Help us help you: attach a .love.
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Why does setColor wrap values over 255?
Unless there is a roadmap somewhere I'm unaware of, this 1.0 stable thing is nonsense.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.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Why does setColor wrap values over 255?
Oh, there is a roadmap. It's all here, in my head.
Help us help you: attach a .love.
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Why does setColor wrap values over 255?
Robin wrote:Oh, there is a roadmap. It's all here, in my head.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Why does setColor wrap values over 255?
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.
Who is online
Users browsing this forum: Bing [Bot] and 6 guests