Debian Codegraph @

common/2d/circle.cpp

raw
1 /*
2 * Portions of this file are copyright Rebirth contributors and licensed as
3 * described in COPYING.txt.
4 * Portions of this file are copyright Parallax Software and licensed
5 * according to the Parallax license below.
6 * See COPYING.txt for license details.
7
8 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
9 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
10 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
11 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
12 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
13 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
14 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
15 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
16 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
17 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
18 */
19
20
21 #include "u_mem.h"
22 #include "gr.h"
23
24 namespace dcx {
25
26 #if !DXX_USE_OGL
27 int gr_ucircle(grs_canvas &canvas, const fix xc1, const fix yc1, const fix r1, const color_palette_index color)
28 {
29 int p,x, y, xc, yc, r;
30
31 r = f2i(r1);
32 xc = f2i(xc1);
33 yc = f2i(yc1);
34 p=3-(r*2);
35 x=0;
36 y=r;
37
38 while(x<y)
39 {
40 // Draw the first octant
41 gr_upixel(canvas.cv_bitmap, xc - y, yc - x, color);
42 gr_upixel(canvas.cv_bitmap, xc + y, yc - x, color);
43 gr_upixel(canvas.cv_bitmap, xc - y, yc + x, color);
44 gr_upixel(canvas.cv_bitmap, xc + y, yc + x, color);
45
46 if (p<0)
47 p=p+(x<<2)+6;
48 else {
49 // Draw the second octant
50 gr_upixel(canvas.cv_bitmap, xc - x, yc - y, color);
51 gr_upixel(canvas.cv_bitmap, xc + x, yc - y, color);
52 gr_upixel(canvas.cv_bitmap, xc - x, yc + y, color);
53 gr_upixel(canvas.cv_bitmap, xc + x, yc + y, color);
54 p=p+((x-y)<<2)+10;
55 y--;
56 }
57 x++;
58 }
59 if(x==y) {
60 gr_upixel(canvas.cv_bitmap, xc - x, yc - y, color);
61 gr_upixel(canvas.cv_bitmap, xc + x, yc - y, color);
62 gr_upixel(canvas.cv_bitmap, xc - x, yc + y, color);
63 gr_upixel(canvas.cv_bitmap, xc + x, yc + y, color);
64 }
65 return 0;
66 }
67
68 #endif //!OGL
69
70 }