We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › what means "maskColor >> 16 & 0xFF&
Page Index Toggle Pages: 1
what means "maskColor >> 16 & 0xFF& (Read 548 times)
what means "maskColor >> 16 & 0xFF&
Aug 30th, 2007, 4:48pm
 
hello,

what means

int maskColor = = 0xFF000000;
dist(maskColor >> 16 & 0xFF, maskColor >> 8 & 0xFF, maskColor & 0xFF,
     this.pixels[i] >> 16 & 0xFF, this.pixels[i] >> 8 & 0xFF, this.pixels[i] & 0xFF);

i know the distance-thing and i know that it find out a color-distance of a pixel to another color. but what means that >>?

thanks
mo
Re: what means "maskColor >> 16 & 0
Reply #1 - Aug 30th, 2007, 5:25pm
 
the >> is for shifting a value..
A color is really an int in disguise, and to store all those values in one int, they use shifting.
It's basically like writing hex with numbers, and shoving it in to an int.

I think the maskColor >> 16 & 0xFF does the same as the function red(maskColor).. there are also functions for green, blue, and alpha..

Hope this helps!

seltar
Re: what means "maskColor >> 16 & 0
Reply #2 - Sep 1st, 2007, 4:09pm
 
mobic,
This is covered in detail in the Math reference of Appendix B in Processing:Creative Coding and Computational Art.

Ira
Page Index Toggle Pages: 1