Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Converting rgb to... um, rgb?
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lapsus Antepedis




PostPosted: Sat Jul 23, 2005 9:19 pm   Post subject: Converting rgb to... um, rgb?

I need help on how to convert 'normal' RGB colour values(0-255) to colour values that can be interpreted by languages like python (as percentages, from 0-1 as a real number). This way I can use web-based colour pickers, and photoshop to find colours for things, and then actually be able to use them in programs...

Did that make any sense? I can't tell if it did or not... Embarassed
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Sat Jul 23, 2005 10:01 pm   Post subject: (No subject)

A bit confusing, if you're not thinking about what I think you're thinking. (hah, get it?)

If you have an colour with RGB values ranging from 0 to 255, and you want it as a percentage, why not just divide?
Eg. You have colour red defined as (255, 0, 0). And you want that to be (1.0, 0.0, 0.0). Which is really just a matter of (255/255.0, 0/255.0, 0/255.0)

What did you mean by having a language like Python interpret the colour values? I'll admit I haven't gotten as far as I should've in Dive into Python, but I'm pretty sure there isn't much (if anything) about colour. Which leads me to assume you meant pyOpenGL.

And in that case, though I have yet to test it, you can still use the RGB values in the 0 to 255 range.
Eg.
code:
glColor3ub(255, 255, 255)

Should set the colour to white.

I hope that was helpful to you.
Lapsus Antepedis




PostPosted: Sun Jul 24, 2005 2:06 am   Post subject: (No subject)

Coutsos wrote:

If you have an colour with RGB values ranging from 0 to 255, and you want it as a percentage, why not just divide?
Eg. You have colour red defined as (255, 0, 0). And you want that to be (1.0, 0.0, 0.0). Which is really just a matter of (255/255.0, 0/255.0, 0/255.0)

Ah, I knew that I was forgetting something simple, I didn't have the ".0" on the end. That should make a big difference.

Coutsos wrote:

What did you mean by having a language like Python interpret the colour values? I'll admit I haven't gotten as far as I should've in Dive into Python, but I'm pretty sure there isn't much (if anything) about colour. Which leads me to assume you meant pyOpenGL.

Actually, I am using the visual module, it just seems easier to me somehow. I was using python as an example because that's what I was using at that moment. Another example that comes to mind is the Stepmania metrics files, but I doubt many people would recognise that anyway, and it's changing completely soon, so that example would have just confused people...

Coutsos wrote:

I hope that was helpful to you.

Very helpful! Thank you!
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: