Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get variations of a color in AS3

I download a script and in it, it had this code which generates a variation of green. I am not sure I understand it. I would like to modify it to get a desired color with different variations. Can anyone explain this snippet to me?

var color:uint = 0 | int(getRandom(80, 256)) << 8 | 0;
like image 848
brenjt Avatar asked Feb 04 '26 14:02

brenjt


1 Answers

I figured it out.

There are three different colors in the uint. RGB.

var color = RED << 16 | GREEN << 8 | BLUE;

That makes up a color in which you can use. To make the example above generate a random yellow color I would just use:

var color = int(getRandom(180, 255)) << 16 | int(getRandom(180, 230)) << 8 | 0;
like image 109
brenjt Avatar answered Feb 06 '26 06:02

brenjt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!