Understanding code

float c = ((img.pixels[(x+y*img.width)] >> 8) & 0xFF)/255.0;

can you tell me what this code is doing - I know it is extracting G value of RGB and then is it diving by 255 to get hex value?

Thanks!

2 Likes

Hi.
Where did you get that code?
It really gets the float value of the green segment.
But dividing it with 255 makes no sense to me.

I think I’ve got it Noel - I think it’s to constrain the value between 0 & 1.

3 Likes