Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | /* |
2 | * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
||
3 | * It is copyright by its individual contributors, as recorded in the |
||
4 | * project's Git history. See COPYING.txt at the top level for license |
||
5 | * terms and a link to the Git history. |
||
6 | */ |
||
7 | /* |
||
8 | * |
||
9 | * Graphical routines for drawing a disk. |
||
10 | * |
||
11 | */ |
||
12 | |||
13 | #include "u_mem.h" |
||
14 | #include "gr.h" |
||
15 | #include "grdef.h" |
||
16 | |||
17 | namespace dcx { |
||
18 | |||
19 | #if !DXX_USE_OGL |
||
20 | int gr_disk(grs_canvas &canvas, const fix xc1, const fix yc1, const fix r1, const uint8_t color) |
||
21 | { |
||
22 | int p,x, y, xc, yc, r; |
||
23 | |||
24 | r = f2i(r1); |
||
25 | xc = f2i(xc1); |
||
26 | yc = f2i(yc1); |
||
27 | p=3-(r*2); |
||
28 | x=0; |
||
29 | y=r; |
||
30 | |||
31 | // Big clip |
||
32 | if (xc + r < 0) |
||
33 | return 1; |
||
34 | if (xc - r > canvas.cv_bitmap.bm_w) |
||
35 | return 1; |
||
36 | if (yc + r < 0) |
||
37 | return 1; |
||
38 | if (yc - r > canvas.cv_bitmap.bm_h) |
||
39 | return 1; |
||
40 | |||
41 | while(x<y) |
||
42 | { |
||
43 | // Draw the first octant |
||
44 | gr_scanline(canvas, xc-y, xc+y, yc-x, color); |
||
45 | gr_scanline(canvas, xc-y, xc+y, yc+x, color); |
||
46 | |||
47 | if (p<0) |
||
48 | p=p+(x<<2)+6; |
||
49 | else { |
||
50 | // Draw the second octant |
||
51 | gr_scanline(canvas, xc-x, xc+x, yc-y, color); |
||
52 | gr_scanline(canvas, xc-x, xc+x, yc+y, color); |
||
53 | p=p+((x-y)<<2)+10; |
||
54 | y--; |
||
55 | } |
||
56 | x++; |
||
57 | } |
||
58 | if(x==y) { |
||
59 | gr_scanline(canvas, xc-x, xc+x, yc-y, color); |
||
60 | gr_scanline(canvas, xc-x, xc+x, yc+y, color); |
||
61 | } |
||
62 | return 0; |
||
63 | } |
||
64 | |||
65 | #endif |
||
66 | |||
67 | } |