Hello everybody.
I have an assigment and amongst other questions on of them specifies:
Create a bmp image 256x256 with 225(color) backround and a circle of varying radius given by the user with 64(color). Circle's center will be image's center.
Since the center will be the images center we know that circle's center would be 128,128, and getting radius r from the user i suppose i can use pythagoras (x-xo)^2 +(y-yo)^2=r^2~~~~~xo,yo=128.
so scanning the whole 256x256 "map" of the image i want to color every image[i][j] that validates (x-xo)^2 +(y-yo)^2< r^2
to create the disc of the circle.
As much as i try i always get something like a diagonal line from top right to top left, and not a circle. my code is:
Code:
for(int i=0; i<256; i++)
{
di=(i-128)^2;
for(j=0; j<256; j++)
{
dj=(j-128)^2;
if((di+dj)<(r^2))
{
image[i][j]=(unsigned char*)64;
}
}
}
any hints?