Question

I am using graphics.h library to implement the a shutdown button on the display screen.The problem I am facing is that the color function(setfillcolor()) is not working by which I want to color the area between the two circles in red.My compiler is turbo C.

   void shutdown(void)
    { 
    setcolor(RED);
    circle(550,50,10);
    setfillcolor(RED);
    //color.
    circle(550,50,15);
    setcolor(CYAN);
    }

alt text

Was it helpful?

Solution

does setfillcolor just set the fill colour? i.e does it actually draw anything?

to maybe fill in your background you may have to find its rectangle and maybe call FilledRectangle (i dont know the function names sorry) before you draw both your circles?

so something like this: (psuedo-code)

  1. set fill colour
  2. draw background rectangle
  3. set cirlce 1 colour
  4. draw circle 1
  5. set cirlce 2 colour
  6. draw circle 2

sorry if im barking up the wrong tree!


EDIT:

there are a few too many maybe's youre right ;) here are two attempts at an answer to my interpretations of your question (though im not entirely sure what you are after):

answer 1:

try something like this

void shutdown(void)
{ 
setfillcolor(BLACK);
FilledRectangle(screenRectLeft, screenRectTop,
    screenRectRight, screenRectBottom);

setcolor(CYAN);
circle(550,50,15);

setcolor(RED);
circle(550,50,10);
}

where screenRectLeft, screenRectTop, screenRectRight and screenRectBottom are the extents of the screen rectangle. what this does is set the fill colour to be used when a filled shape is drawn. a filled rectangle is then drawn with the extents of the screen, which you must provide. then the circles are drawn, over the already drawn filled rectangle. the order the circles are drawn has been switched so that the larger circle does not overdraw the smaller circle (i assume this is what you want).

answer 2:

if you mean that you want two rings, each with the same central point to be drawn, with the space between them to be the background colour, you will have to draw concentric circles, inwards from the largest circle, something like this:

void shutdown(void)
{ 
setfillcolor(BLACK);
FilledRectangle(screenRectLeft, screenRectTop,
    screenRectRight, screenRectBottom);

setcolor(RED);
circle(550,50,20);

setcolor(BLACK);
circle(550,50,15);

setcolor(RED);
circle(550,50,10);

setcolor(BLACK);
circle(550,50,5);
}

that should (i think, cant test) draw two red rings. you can adjust the radii to your liking :o


hope this helps!?

p.s. i have just seen the image underneath your post - if that is the sort of result you are after i would strongly suggest using a more powerful/up-to-date graphics library if possible!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top