ALLEGRO: help with ARC

ALLEGRO: help with ARC

Post by hele » Tue, 25 Feb 2003 21:50:56



I am using Allegro with DJGPP on a win98 OS.
Everything works fine, but I can't get this to work properly:
(look under for more questions and details)

/*
 *    Example program for the Allegro library, by Shawn Hargreaves.
 *
 *    This is a very simple program showing how to get into graphics
 *    mode and put pixels onto the screen.
 */

#include "allegro.h"

int main()
{
        int i,k;
   /* you should always do this at the start of Allegro programs */
   allegro_init();

   /* set up the keyboard handler */
   install_keyboard();

   /* set a graphics mode sized 320x200 */
   if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Unable to set any graphic mode\n%s\n",
allegro_error);
      return 1;
   }

   /* set the color palette */
   set_palette(desktop_palette);

   /* clear the screen to white */
   clear_to_color(screen, makecol(255, 255, 255));

   /* you don't need to do this, but on some platforms (eg. Windows)
things
    * will be drawn more quickly if you always acquire the screen before
    * trying to draw onto it.
    */
   acquire_screen();

   // Now prepare a arc...

        arc(screen, 100, 100, 60,200, 50,4);

    readkey();

   /* you must always release bitmaps before calling any input functions
*/
   release_screen();

   /* wait for a keypress */
   readkey();

   return 0;

Quote:}

END_OF_MAIN();
----------

I only want to draw an arc on the screen, say from 30 degrees to 300
degrees.
I am not sure what kind of numbers to use to specify the degrees
in the ARc primitive.

HELP says
void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);
Draws a circular arc with centre x, y and radius r, in an anticlockwise
direction starting from the angle a1 and ending when it reaches a2.
These values are specified in 16.16 fixed point format, with 256 equal
to a full circle, 64 a right angle, etc. Zero is to the right of the
centre point, and larger values rotate anticlockwise from there.

thank you

helen


--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

 
 
 

ALLEGRO: help with ARC

Post by Kev » Wed, 26 Feb 2003 02:20:23


On Mon, 24 Feb 2003 12:50:56 +0000 (UTC), "helen"


>I am using Allegro with DJGPP on a win98 OS.
>Everything works fine, but I can't get this to work properly:
>(look under for more questions and details)

>/*
Snip
>HELP says
>void arc(BITMAP *bmp, int x, y, fixed ang1, ang2, int r, int color);
>Draws a circular arc with centre x, y and radius r, in an anticlockwise
>direction starting from the angle a1 and ending when it reaches a2.
>These values are specified in 16.16 fixed point format, with 256 equal
>to a full circle, 64 a right angle, etc. Zero is to the right of the
>centre point, and larger values rotate anticlockwise from there.

>thank you

>helen



The start angle, ang1 is 30, this is a twelth of a circle.
a twelth of 256 is 21.3 recurring

the end angle is 300 this is 5/6 of a circle and 5/6
of 256 is 213.3 recurring

So, I would say that ang1 should be 21.333
and ang2 should be 213.333

Never used the arc() function myself, but this feels about right

Kev.

 
 
 

ALLEGRO: help with ARC

Post by Silvio Darz » Wed, 26 Feb 2003 18:50:21


Quote:

> The start angle, ang1 is 30, this is a twelth of a circle.
> a twelth of 256 is 21.3 recurring

> the end angle is 300 this is 5/6 of a circle and 5/6
> of 256 is 213.3 recurring

> So, I would say that ang1 should be 21.333
> and ang2 should be 213.333

> Never used the arc() function myself, but this feels about right

> Kev.

I thought it was light that but the problem are 16.16 fixed point
numbers.

I now found out functions like

int fixtoi(fixed x);

converting an integer to a fixed
and it works fine

try this:

arc(screen,x+10,y+10,itofix(64),itofix(128),10,col);
                arc(screen,x+10,y+h-10,itofix(128),itofix(192),10,col);
                arc(screen,x+w-10,y+10,itofix(0),itofix(64),10,col);
                arc(screen,x+w-10,y+h-10,itofix(192),itofix(256),10,col);

                hline(screen,x+10,y,x+w-10,col);
                hline(screen,x+10,y+h,x+w-10,col);
                vline(screen,x,y+10,y+h-10,col);
                vline(screen,x+w,y+10,y+h-10,col);

byebye
helen

--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG

 
 
 

1. Drawing circle arc-segments with spline() in Allegro

Hello,
I need to find a good way to draw segments of a circle (for the
purpose of drawing lenses).  The spline method seems to be a good way
to do it, but I can't figure out where the two middle points should
be.  One must be on each tangent (to the circle at the curve
end-points), but how far along?

TIA

--

2. autobooting cds

3. ARC and TYT files, help needed

4. HM2007 speech recognition

5. PLEASE HELP: Where can I get arc and zoo???

6. pop up screens

7. problem with fixed datatype (drawing simple arcs / pie segments)

8. Compiling C++

9. Need: un-archiver for .arc dr-dobbs files

10. your mail about arc-cosine

11. .zip .zoo .arc

12. TSBAT27.ARC batch collection update at garbo.uwasa.fi

13. Drawing elliptical arcs where the "parent" ellipse is inclined