# Color, RGB and Bit numbers

**URL:** <https://forum.kirupa.com/t/color-rgb-and-bit-numbers/295381>\
**Category:** flash\
**Created:** [August 28, 2009, 8:50pm UTC](https://forum.kirupa.com/t/color-rgb-and-bit-numbers/295381 "2009-08-28T20:50:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan0](https://avatars.discourse-cdn.com/v4/letter/d/97f17d/32.png) [@Dan0](https://forum.kirupa.com/u/Dan0)\
**Post date:** [August 28, 2009, 8:50pm UTC](https://forum.kirupa.com/t/color-rgb-and-bit-numbers/295381/1 "2009-08-28T20:50:07Z")

</div>

Hi, I have been playing around with this code at wonderfl. I can not find anywhere what this section of code means (I found it hard to search because of funny \>\> symbols).

Please could anyone enlighten me on what the color modification is actually doing line by line… The overall effect is an ‘addative’ blend (e.g. lots of particles on one pixel will make it white) but I’m not sure what the stuff in the lines means and why is r\>\>16 and g\>\>8 ?

The link is here, lines 300-306: [http://wonderfl.net/code/e14259ff3fed2a9bcc58f3d9bb17fd586c940b8b](http://wonderfl.net/code/e14259ff3fed2a9bcc58f3d9bb17fd586c940b8b)

The lines in question:

```auto
col = canvas.getPixel(int(prt.x), int(prt.y));
r = (col>>16&0xff) + prt.r*colTransR;
g = (col>>8&0xff) + prt.g*colTransG;
b = (col&0xff) + prt.b*colTransB;
r = (r<0xff)? r : 0xff;
g = (g<0xff)? g : 0xff;
b = (b<0xff)? b : 0xff;
canvas.setPixel(int(prt.x), int(prt.y), (r<<16)|(g<<8)|b);

```

Any help is greatly appreciated :). Also if you could tell me where I can learn this myself (books or websites) I would love that instead of using people’s time here xD,  
Dan
