How can I find each and every pixel in a circle so that I can do some operations on it.
Thanks.
How can I find each and every pixel in a circle so that I can do some operations on it.
Thanks.
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.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
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.
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.
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?
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
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; } }