]> icculus.org git repositories - btb/d2x.git/blob - 2d/disc.c
use the orientation parameter of g3_draw_bitmap
[btb/d2x.git] / 2d / disc.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include <conf.h>
16 #endif
17
18 #include "u_mem.h"
19 #include "gr.h"
20
21
22 int gr_disk(fix xc1,fix yc1,fix r1)
23 {
24         int p,x, y, xc, yc, r;
25
26         r = f2i(r1);
27         xc = f2i(xc1);
28         yc = f2i(yc1);
29         p=3-(r*2);
30         x=0;
31         y=r;
32
33         // Big clip
34         if ( (xc+r) < 0 ) return 1;
35         if ( (xc-r) > GWIDTH ) return 1;
36         if ( (yc+r) < 0 ) return 1;
37         if ( (yc-r) > GHEIGHT ) return 1;
38
39         while(x<y)
40         {
41                 // Draw the first octant
42                 gr_scanline( xc-y, xc+y, yc-x );
43                 gr_scanline( xc-y, xc+y, yc+x );
44
45                 if (p<0)
46                         p=p+(x<<2)+6;
47                 else {
48                         // Draw the second octant
49                         gr_scanline( xc-x, xc+x, yc-y );
50                         gr_scanline( xc-x, xc+x, yc+y );
51                         p=p+((x-y)<<2)+10;
52                         y--;
53                 }
54                 x++;
55         }
56         if(x==y) {
57                 gr_scanline( xc-x, xc+x, yc-y );
58                 gr_scanline( xc-x, xc+x, yc+y );
59         }
60         return 0;
61 }
62
63 int gr_udisk(fix xc1,fix yc1,fix r1)
64 {
65         int p,x, y, xc, yc, r;
66
67         r = f2i(r1);
68         xc = f2i(xc1);
69         yc = f2i(yc1);
70         p=3-(r*2);
71         x=0;
72         y=r;
73
74         while(x<y)
75         {
76                 // Draw the first octant
77                 gr_uscanline( xc-y, xc+y, yc-x );
78                 gr_uscanline( xc-y, xc+y, yc+x );
79
80                 if (p<0)
81                         p=p+(x<<2)+6;
82                 else {
83                         // Draw the second octant
84                         gr_uscanline( xc-x, xc+x, yc-y );
85                         gr_uscanline( xc-x, xc+x, yc+y );
86                         p=p+((x-y)<<2)+10;
87                         y--;
88                 }
89                 x++;
90         }
91         if(x==y) {
92                 gr_uscanline( xc-x, xc+x, yc-y );
93                 gr_uscanline( xc-x, xc+x, yc+y );
94         }
95         return 0;
96 }
97