Re: semicircle

Search this archive.

From: Jay Link (jlink@interlink-bbs.com)
Date: Mon 29 Nov 1999 - 20:39:37 IST


> does anyone knows how do I fill a semicircle ?

Easy way: draw a complete circle with gl_circle(), and then erase half of
it with gl_fillbox(). Use gl's framebuffer if you don't want to erase your
background, i.e., draw to the framebuffer, and then transfer to the
physical screen.

Harder (but better) way: copy the gl_circle() function from the line.c
source file in SVGAlib's gl subdirectory. You will also need the
gl_setcirclepixels() function, which is called by gl_circle(). You will
notice that gl_setcirclepixels() has eight drawing commands to speed up
the process. They look like this:

    setpixel(sx + x, sy + y, c);
    setpixel(sx - x, sy + y, c);
    setpixel(sx + x, sy - y, c);
    setpixel(sx - x, sy - y, c);
    setpixel(sx + y, sy + x, c);
    setpixel(sx - y, sy + x, c);
    setpixel(sx + y, sy - x, c);
    setpixel(sx - y, sy - x, c);

Remove the four that you don't need. (This assumes that your semicircle is
exactly 1/2 of a full circle).

HTH,

-Jay Link


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST