Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 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
 
23
#include "gr.h"
24
#include "grdef.h"
25
 
26
namespace dcx {
27
 
28
#if !DXX_USE_OGL
29
int gr_ucircle(grs_canvas &canvas, const fix xc1, const fix yc1, const fix r1, const color_palette_index color)
30
{
31
        int p,x, y, xc, yc, r;
32
 
33
        r = f2i(r1);
34
        xc = f2i(xc1);
35
        yc = f2i(yc1);
36
        p=3-(r*2);
37
        x=0;
38
        y=r;
39
 
40
        while(x<y)
41
        {
42
                // Draw the first octant
43
                gr_upixel(canvas.cv_bitmap, xc - y, yc - x, color);
44
                gr_upixel(canvas.cv_bitmap, xc + y, yc - x, color);
45
                gr_upixel(canvas.cv_bitmap, xc - y, yc + x, color);
46
                gr_upixel(canvas.cv_bitmap, xc + y, yc + x, color);
47
 
48
                if (p<0)
49
                        p=p+(x<<2)+6;
50
                else {
51
                        // Draw the second octant
52
                        gr_upixel(canvas.cv_bitmap, xc - x, yc - y, color);
53
                        gr_upixel(canvas.cv_bitmap, xc + x, yc - y, color);
54
                        gr_upixel(canvas.cv_bitmap, xc - x, yc + y, color);
55
                        gr_upixel(canvas.cv_bitmap, xc + x, yc + y, color);
56
                        p=p+((x-y)<<2)+10;
57
                        y--;
58
                }
59
                x++;
60
        }
61
        if(x==y) {
62
                gr_upixel(canvas.cv_bitmap, xc - x, yc - y, color);
63
                gr_upixel(canvas.cv_bitmap, xc + x, yc - y, color);
64
                gr_upixel(canvas.cv_bitmap, xc - x, yc + y, color);
65
                gr_upixel(canvas.cv_bitmap, xc + x, yc + y, color);
66
        }
67
        return 0;
68
}
69
 
70
#endif //!OGL
71
 
72
}