graphics.h does not exist for Borland 5.5, so it won't work.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
>problem of using the floodfill() function
Could there be a possible bug in your floodfill() algorithm?
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
> So I tried TURBO C++ 3.0. And it worked perfectly
Basically, you have a choice.
- Stick with a 16 bit compiler, and low resolution graphics library from antiquity.
- Upgrade to a more modern 32 bit compiler, and learn a new graphical API (say OpenGL).
> it does not colour the circle but the color is spread out all over the screen
1. You didn't paste your attempt at using floodfill.
2. You set the seed point outside the circle?
3. Your circle has a hole in the perimeter - this is a bug in circle, if circles are meant to draw closed shapes which can be flood filled.
Oh, and main returns int, not void
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
You first need to draw the cirle and then do a flood fill, not after it. Swap the 'circle' and 'floodfill' statements.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
> I don't know what is OpenGL
If you want to make it as a programmer, your first reaction to asking "what is foo" is to type in "foo" into a search engine, and see if you can't get some information for yourself.
http://www.opengl.org/
And to get you going
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01
Scroll down to the end for a partial list of the platforms which OpenGL can be used with.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Any point inside any closed figure.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Maybe posting the entire code in code tags would help your cause.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
This is happening because you are setting the fill color as well as the border color of the fill to the same color i.e. RED.
This is confusing the floodfill algorithm which checks the color of the neighboring pixels to determine when to stop. By making the border RED, the check is never unsuccessful and it fills up the entire screen. This seems to be a bug with the function since this is not expected but you have got to live with it. :-)
Choose different colors for floodfilling and its border and you should be fine. Oh and BTW, main returns an int and not void.
#include<stdio.h>
#include<graphics.h>
//you don't need conio
int main(void)
{
int driver,mode;
driver = DETECT;
initgraph(&driver,&mode,"\\tc\\bgi");
rectangle(105,90,125,110);
setfillstyle(SOLID_FILL, RED);
floodfill(115, 100, WHITE);
getchar();
closegraph();
return(0);
}
}
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734
Read this . Simple and short answer: As far as the standards are concerned, main() always has returned an int as its exit status.
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734