Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Daraketh

Cycling through all available colours

Question

I'm writing a pointless program to start learning about how the GPU api works. It's basically a shrinking and expanding square that changes the border colour and inner square colour every update.

 

I'm wondering if there is a trivial way to cycle through all the colours starting from black to white, and in reverse, as below.

 

post-486-0-81205900-1424859686_thumb.jpg

 

Link below is what I have so far, unfortunately it hasn't got many comments, and my code is probably pretty noobish. I noticed that the top tier screens are capable of only 8 bit colour, but I seem to need to use up to 16mil+ to get access to get all the possible colours.

 

http://pastebin.com/UKXtPNDt

 

Anyone able to tell me where I'm going wrong, I know I'm not even close.

 

Cheers,

Dara

 

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

OpenComputers indeed only supports 8-bit colors, but still uses hex notation, which can reference over 16.7 million colors, so iterating through all of them would be highly inefficient and would lead to a lot of technically identical colors.

 

@Eunomiac has created a nice reference image showing all colors supported in OC and their hex values, you may find that useful: http://oc.cil.li/index.php?/topic/442-/#entry1751

Link to post
Share on other sites
  • 0

Thanks for the replies to my threads dgelessus!

 

That colour chart in the link was very useful, it helped lead to this program - http://pastebin.com/GPg4XVY5

 

At the moment it uses to GPU to cycle through all available colours as shown in that chart, and prints each colour row by row on the screen (along with it's hex value and brightness value).

 

"colour normal" just prints the colours as shown on the chart, along with the hex and brightness values.

"colour lum" first prints the colours as in "colour normal" in order to fill a table with values for later sorting, then it attempts to do what i described in my original post, but does a pretty poor job of it.

 

I think I've almost got it doing what I want, but at the moment It's only calculating the RBG colour's luminance (brightness) based on the the findings of one gentleman (http://alienryderflex.com/hsp.html). As below

 

brightness  =  sqrt( .299 R2 + .587 G2 + .114 B2 )

 

I think I need to find a way to calculate not only the brightness of the colour, but the contrast ratio also. Anyways, I might play around and see what happens. It was a fun learning experience regardless.

 

Cheers!

Link to post
Share on other sites
  • 0

FYI, you can use hexadecimal number notation anywhere. Lines 8-14 could be written like this:

local red = {}
red[1] = 0x000000
red[2] = 0x330000
red[3] = 0x660000
red[4] = 0x990000
red[5] = 0xCC0000
red[6] = 0xFF0000

The whole color brightness thing now also makes much more sense. In your first post it sounded like you just wanted all distinct colors to loop through all the values more efficiently. I don't know enough about color sciences (is that a thing? lol) to say anything constructive about that part, but hopefully you'll figure it out.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.