# Thread: How to find each pixel in the circle?

1. ## How to find each pixel in the circle?

How can I find each and every pixel in a circle so that I can do some operations on it.

Thanks.

2. Is this
- a circle you need to draw?
- a circle you've already drawn?
- a circle someone else has drawn, and you need to find it in an image?

Not to mention, which OS / Compiler / graphics library are you using.

3. I've already drawn a circle using mid-point algorithm. And I filled the circle, which is white. But I want to fill the circle by calculating the value of hue, saturation of each pixel. So that it shows the different color and intensity.
I am using GLUT, C++ in windows.

4. Lol use this : Fast Robust Predicates for Computational Geometry

Use pixel indices as coordinates and boom! Because those routines are robust, they're never wrong. Never. Ever.

Ever.

5. So, in other words you want to draw a color wheel?

Use the scanline method, and calculate the angle and distance from the centre for each pixel, then color it according to those values. You'll also want some HSV to RGB conversion code.
What part of this do you now need help with?

6. Originally Posted by iMalc
So, in other words you want to draw a color wheel?

Use the scanline method, and calculate the angle and distance from the centre for each pixel, then color it according to those values. You'll also want some HSV to RGB conversion code.
What part of this do you now need help with?

I am stuck with this part that how can I calculate the angle and distance for each pixel? And how can I implement this in my code. I have HSVtoRGB conversion algorithm. But how can I do this entire process?

7. For HSV to RGB conversion I am using following function.

Code:
```void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v){
int i;
float f, p, q, t;
if(s == 0)
{
*r = *g = *b = v;       //acromatic
return;
}

h /= 60;
i = floor(h);
f = h - i;
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));
switch(i)
{
case 0: *r = v; *g = t; *b = p; break;
case 1: *r = q; *g = v; *b = p; break;
case 2: *r = p; *g = v; *b = t; break;
case 3: *r = p; *g = q; *b = v; break;
case 4: *r = t; *g = p; *b = v; break;
case 5: *r = v; *g = p; *b = q; break;
}
}```