Forum Topic: 0xrrggbb To Red, Blue, Green

(90 views • 5 replies)

This topic is 1 page long.

<< < > >>
Questioning

Archon68

Reply To Post Reply & Quote

Posted at: 9/27/09 09:15 AM

Archon68 LIGHT LEVEL 22

Sign-Up: 09/09/07

Posts: 3,482

How can I convert a color in the "0xRRGGBB" format to the red, blue, and green values for that color?

I code in AS2, in case I forgot to mention it.

BBS Signature

None

UnknownFury

Reply To Post Reply & Quote

Posted at: 9/27/09 10:05 AM

UnknownFury EVIL LEVEL 26

Sign-Up: 08/10/05

Posts: 6,027

var colour : Number = 0xFF0000;
var r = colour >> 16 & 0xFF;
var g = colour >> 8 & 0xFF;
var b = colour & 0xFF;

>> is the bitwise right shift operator and & is the bitwise and operator.

Portfolio(Under construction): UnknownFury.com |
Msn: giant_ak_47@msn.com | Contact: me@unknownfury.com
Follow me on twitter!


Sad

matrix5565

Reply To Post Reply & Quote

Posted at: 9/27/09 10:13 AM

matrix5565 LIGHT LEVEL 15

Sign-Up: 02/28/06

Posts: 568

I wish I had known it was that easy.


None

Archon68

Reply To Post Reply & Quote

Posted at: 9/27/09 10:47 AM

Archon68 LIGHT LEVEL 22

Sign-Up: 09/09/07

Posts: 3,482

At 9/27/09 10:05 AM, UnknownFury wrote: var colour : Number = 0xFF0000;
var r = colour >> 16 & 0xFF;
var g = colour >> 8 & 0xFF;
var b = colour & 0xFF;

>> is the bitwise right shift operator and & is the bitwise and operator.

Thanks!

I code in AS2, in case I forgot to mention it.

BBS Signature

None

Yambanshee

Reply To Post Reply & Quote

Posted at: 9/27/09 11:18 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

At 9/27/09 10:13 AM, matrix5565 wrote: I wish I had known it was that easy.

haha :/ poor you going through all that effort and getting owned by 3 lines of code :P

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 06:15 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!