📄 guiarc.lst
字号:
C51 COMPILER V8.05a GUIARC 04/11/2008 14:18:53 PAGE 1
C51 COMPILER V8.05a, COMPILATION OF MODULE GUIARC
OBJECT MODULE PLACED IN guiarc.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\guiarc.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND PR
-INT(.\guiarc.lst) OBJECT(guiarc.obj)
line level source
1 /*
2 *********************************************************************************************************
3 * uC/GUI
4 * Universal graphic software for embedded applications
5 *
6 * (c) Copyright 2002, Micrium Inc., Weston, FL
7 * (c) Copyright 2002, SEGGER Microcontroller Systeme GmbH
8 *
9 * 礐/GUI is protected by international copyright laws. Knowledge of the
10 * source code may not be used to write a similar product. This file may
11 * only be used in accordance with a license and should not be redistributed
12 * in any way. We appreciate your understanding and fairness.
13 *
14 ----------------------------------------------------------------------
15 File : GUIARCFloat.C
16 Purpose : Draw Arc routines based on floating point
17 ----------------------------------------------------------------------
18 Version-Date---Author-Explanation
19 ----------------------------------------------------------------------
20 2.00.00 000325 RS First release of the new algorithm
21 ----------------------------------------------------------------------
22 Known problems or limitations with current version
23 ----------------------------------------------------------------------
24 None.
25 ----------------------------------------------------------------------
26 Open issues
27 ----------------------------------------------------------------------
28 None
29 ---------------------------END-OF-HEADER------------------------------
30 */
31
32 #include <stddef.h> /* needed for definition of NULL */
33 #include <math.h>
34 #include "gui\Core\GUI_Private.h"
35
36
37
38 static void CalcX(int*px, int y, U32 r2) {
39 1 int x =*px;
40 1 U32 y2 = (U32)y*(U32)y;
41 1 U32 r2y2 = r2-y2;
42 1 U32 x2;
43 1 if (y2>=r2) {
44 2 *px=0;
45 2 return;
46 2 }
47 1 /* x2 = r2-y2 */
48 1 do {
49 2 x++;
50 2 x2 =(U32)x*(U32)x;
51 2 } while (x2 < r2y2);
52 1 *px = x-1;
53 1 }
54
C51 COMPILER V8.05a GUIARC 04/11/2008 14:18:53 PAGE 2
55 static float CalcInterSectLin(float y, float y0, float y1, float x0, float x1) {
56 1 if (y1==y0) {
57 2 return y0;
58 2 } else {
59 2 float Slope = (x1-x0)/(y1-y0);
60 2 return (y-y0)*Slope+x0;
61 2 }
62 1 }
63
64 static void _DrawArc(int x0, int y0, int rx, int ry, int Angle0, int Angle1, int xMul, int yMul) {
65 1 float afx[4];
66 1 float afy[4];
67 1 float ri = rx-(GUI_Context.PenSize+1.5)/2;
68 1 float ro = rx+(GUI_Context.PenSize+1.5)/2;
69 1 float fAngle0 = Angle0*3.1415926/180;
70 1 float fAngle1 = Angle1*3.1415926/180;
71 1 float sin0 = sin(fAngle0);
72 1 float sin1 = sin(fAngle1);
73 1 float cos0 = cos(fAngle0);
74 1 float cos1 = cos(fAngle1);
75 1 U32 ri2 = ri*ri;
76 1 U32 ro2 = ro*ro;
77 1 int y, yMax, yMin;
78 1 afy[0] = ri*sin0;
79 1 afy[1] = ro*sin0;
80 1 afy[2] = ri*sin1;
81 1 afy[3] = ro*sin1;
82 1 afx[0] = ri*cos0;
83 1 afx[1] = ro*cos0;
84 1 afx[2] = ri*cos1;
85 1 afx[3] = ro*cos1;
86 1 yMin = ceil(afy[0]);
87 1 yMax = floor(afy[3]);
88 1 /* Use Clipping rect to reduce calculation (if possible) */
89 1 if (GUI_Context.pClipRect_HL) {
90 2 if (yMul ==1) {
91 3 if (yMax > (GUI_Context.pClipRect_HL->y1 -y0))
92 3 yMax = (GUI_Context.pClipRect_HL->y1 -y0);
93 3 if (yMin < (GUI_Context.pClipRect_HL->y0 -y0))
94 3 yMin = (GUI_Context.pClipRect_HL->y0 -y0);
95 3 }
96 2 if (yMul == -1) {
97 3 if (yMin > (GUI_Context.pClipRect_HL->y1 -y0))
98 3 yMin = (GUI_Context.pClipRect_HL->y1 -y0);
99 3 if (yMax < (GUI_Context.pClipRect_HL->y0 -y0))
100 3 yMax = (GUI_Context.pClipRect_HL->y0 -y0);
101 3 }
102 2 }
103 1 /* Start drawing lines ... */
104 1 {
105 2 int xMinDisp, xMaxDisp, xMin=0,xMax=0;
106 2 for (y=yMax; y>=yMin; y--) {
107 3 CalcX(&xMin, y, ri2);
108 3 CalcX(&xMax, y, ro2);
109 3 if ((float)y< afy[1]) {
110 4 xMaxDisp = CalcInterSectLin(y,afy[0], afy[1], afx[0], afx[1]);
111 4 } else {
112 4 xMaxDisp = xMax;
113 4 }
114 3 if ((float)y > afy[2]) {
115 4 xMinDisp = CalcInterSectLin(y,afy[2], afy[3], afx[2], afx[3]);
116 4 } else {
C51 COMPILER V8.05a GUIARC 04/11/2008 14:18:53 PAGE 3
117 4 xMinDisp = xMin;
118 4 }
119 3 if (xMul>0)
120 3 LCD_HL_DrawHLine(xMinDisp+x0, yMul*y+y0, xMaxDisp+x0);
121 3 else
122 3 LCD_HL_DrawHLine(-xMaxDisp+x0, yMul*y+y0, -xMinDisp+x0);
123 3 }
124 2 }
125 1 #if 0 /* Test code */
{
int i;
GUI_SetColor( GUI_WHITE );
for (i=0; i<4; i++)
LCD_HL_DrawPixel(afx[i]+x0, afy[i]+y0);
}
#endif
133 1 GUI_USE_PARA(ry);
134 1 }
135
136 void GL_DrawArc (int x0, int y0, int rx, int ry, int a0, int a1) {
137 1 int aEnd;
138 1 a0+=360;
139 1 a1+=360;
140 1 while (a0>=360) {
141 2 a0 -= 360;
142 2 a1 -= 360;
143 2 }
144 1 /* Do first quadrant 0-90 degree */
145 1 DoFirst:
146 1 if (a1<=0)
147 1 return;
148 1 if (a0<90) {
149 2 if (a0<0)
150 2 a0=0;
151 2 aEnd = (a1<90) ? a1 : 90;
152 2 _DrawArc(x0,y0,rx,ry,a0,aEnd, 1, -1);
153 2 }
154 1 a1-=90;
155 1 a0-=90;
156 1 /* Do second quadrant 90-180 degree */
157 1 if (a1<=0)
158 1 return;
159 1 if (a0<90) {
160 2 if (a0<0)
161 2 a0=0;
162 2 aEnd = (a1<90) ? a1 : 90;
163 2 _DrawArc(x0,y0,rx,ry,90-aEnd, 90-a0,-1,-1);
164 2 }
165 1 a1-=90;
166 1 a0-=90;
167 1 /* Do third quadrant 180-270 degree */
168 1 if (a1<=0)
169 1 return;
170 1 if (a0<90) {
171 2 if (a0<0)
172 2 a0=0;
173 2 aEnd = (a1<90) ? a1 : 90;
174 2 _DrawArc(x0,y0,rx,ry,a0,aEnd, -1, 1);
175 2 }
176 1 a1-=90;
177 1 a0-=90;
178 1 /* Do last quadrant 270-360 degree */
C51 COMPILER V8.05a GUIARC 04/11/2008 14:18:53 PAGE 4
179 1 if (a1<=0)
180 1 return;
181 1 if (a0<90) {
182 2 if (a0<0)
183 2 a0=0;
184 2 aEnd = (a1<90) ? a1 : 90;
185 2 _DrawArc(x0,y0,rx,ry,90-aEnd, 90-a0,1,1);
186 2 }
187 1 a1-=90;
188 1 a0-=90;
189 1 goto DoFirst;
190 1 }
191
192 void GUI_DrawArc (int x0, int y0, int rx, int ry, int a0, int a1) {
193 1 GUI_LOCK();
194 1 #if (GUI_WINSUPPORT)
WM_ADDORG(x0,y0);
WM_ITERATE_START(NULL) {
#endif
198 1 GL_DrawArc( x0, y0, rx, ry, a0, a1);
199 1 #if (GUI_WINSUPPORT)
} WM_ITERATE_END();
#endif
202 1 GUI_UNLOCK();
203 1 }
204
205
206
207
208
209
210
211
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 3038 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 175
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -