Thread: Representing floats with color?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    166

    Representing floats with color?

    Ok I've got a challenge for you, a nut to crack.

    We have a color class with values r, g, b and a.

    r,g,b and a each go from 0 to 255 as integers.

    How do you make the color value represent any float value? Find some logic for how you could combine the four values to represent a float.

    ..or perhaps a reasonable value like between 0.0f and 1000000.0f. 2-3 decimals would be enough to store.

    Will try to solve this myself in some way too...

    Edit: Things got a bit easier... added a fourth "a" value since we have an alpha channel as well.
    Last edited by DrSnuggles; 12-19-2008 at 03:00 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 05:06 PM
  3. My opinion on skin color
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2003, 12:12 PM
  4. [WinAPI] Developing a color customizable program
    By Templario in forum Windows Programming
    Replies: 6
    Last Post: 02-04-2003, 06:12 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 10:19 AM