Post Reply 
Interpreting color (and why I wish I paid attention in school)
Still haven't done anything
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,022.2988
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.1274
Offline
Post: #4
RE: Interpreting color (and why I wish I paid attention in school)
(11/03/2013 10:38 PM)Tetris999 Wrote:  Also my wrap is terrible, a case statement to check for boundaries, I should probably make some sort of inline function to handle the wrapping, oh well.
Shouldn't be too difficult

C Code
1
2
3
4
5
6
// assumes -256 < n < 511
static inline int WRAP(int n) {
  if(n > 255) return n-256;
  if(n < 0) return n+256;
  return n;
}


Or if it makes sense to you

C Code
static inline int WRAP(int n) {
  return n & 0xFF;
}

12/03/2013 12:23 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Interpreting color - ZiNgA BuRgA - 10/03/2013, 11:02 PM
RE: Interpreting color - Tetris999 - 11/03/2013, 10:38 PM
RE: Interpreting color (and why I wish I paid attention in school) - ZiNgA BuRgA - 12/03/2013 12:23 AM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)

 Quick Theme: