brenjt
brenjt

Reputation: 16297

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;

Upvotes: 3

Views: 327

Answers (1)

brenjt
brenjt

Reputation: 16297

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;

Upvotes: 5

Related Questions