AHK: How BGR Color Works

Sadly, in AutoHotkey scripts  you can’t just demand “LIME” or “GENTLY BURNT ORANGE”. The computer will spit out an error message if you try. It requires a color ID in hexadecimal BGR (Blue, Green, Red) format.

If you’re wondering what the hell that is, you’re not alone.

The simple answer? It’s an 8 digit code assigned to each color. Look them up on Google if you want to preserve your mental health.

Keep reading if you’re less partial to your sanity.

The Complicated Answer

I just relearned how to count, damn it. That’s how complicated this is.

Hex Explained

You see, Color ID’s are made up of a fixed prefix and numbers that represent a combination of blue, green and red.

The amount of those colors can be anywhere between 0 and 255. Here starts the problem of counting. How do you tell the computer to use the max green value (255) if you can only use a 2 digit number?

You use a different counting system by adding letters A-F. That’s how.

BASE10LOWRES

It’s Base-16 because you’re counting by combining 16 characters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f.

If you’re only manipulating one color while the others are at 0, all you really need to know is that lower values are darker than higher ones.

16-BASE EXPLAINED

When you start combining colors, the same normal color rules apply. To make yellow, you jack up the red and green values, so the BGR will read 0x00ffff. Blue and red makes purple, so 0xff00ff.

The oddest thing to get used to is white being the max value of blue, green and red combined, 0xffffff. Just remember that the higher the value, the more they cancel each other out until they reach nothing. White.

Advertisements
Tagged , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: