#### Archived

This topic is now archived and is closed to further replies.

# Need an algorithm for converting 0-n to 0-255

This topic is 6297 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

distance is 0-n, I need to convert the distance to 0-255. If I could I would do it like this for example: increasement=256/max_distance;
  for(x=0;x
But I can''t in this case. I need it to be somehow check with the current distance. Here''s what I''m trying to do with a circle:
  if(x
I know this is an easy question, but my brains are seriously jammed atm and I can''t figure out it by myself right now. So any help would be appritiated. thank you

##### Share on other sites
  double multiplier = 256/n;

now if n were say 128.....the multiplier would be 2
so any distance would be mutliplied by 2 to get the distance in terms of 0 to 255

"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T

##### Share on other sites
Thanks man (I feel so stupid right now )

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013643
×