⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 guicirc.lst

📁 Keil C下通过的UCGUI,UCGUI的移植源代码
💻 LST
字号:
C51 COMPILER V8.05a   GUICIRC                                                              04/11/2008 14:18:55 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE GUICIRC
OBJECT MODULE PLACED IN GUICirc.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE gui\Core\GUICirc.c LARGE BROWSE MDU_F120 DEBUG OBJECTEXTEND P
                    -RINT(.\GUICirc.lst) OBJECT(GUICirc.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        : GUICirc.C
  16          Purpose     : Circle and ellipse drawing functions
  17          ----------------------------------------------------------------------
  18          Version-Date---Author-Explanation
  19          ----------------------------------------------------------------------
  20          1.00.02 011115 JE     a) GL_FillEllipse, GL_FillCircle, GL_DrawCircle changed
  21          1.00.01 011113 JE     a) GL_DrawEllipse changed
  22          1.00.00 991206 RS     First release
  23          ----------------------------------------------------------------------
  24          Known problems or limitations with current version
  25          ----------------------------------------------------------------------
  26          None.
  27          ----------------------------------------------------------------------
  28          Open issues
  29          ----------------------------------------------------------------------
  30          None
  31          ---------------------------END-OF-HEADER------------------------------
  32          */
  33          
  34          
  35          #include <stddef.h>           /* needed for definition of NULL */
  36          #include "gui\Core\GUI_Private.h"
  37          
  38          
  39          /*
  40                *************************************************
  41                *                                               *
  42                *            Draw Circle                        *
  43                *                                               *
  44                *************************************************
  45          */
  46          
  47          static  void Draw8Point(int x0,int y0, int xoff, int yoff) {
  48   1        LCD_HL_DrawPixel(x0+xoff,y0+yoff);
  49   1        LCD_HL_DrawPixel(x0-xoff,y0+yoff);
  50   1        LCD_HL_DrawPixel(x0+yoff,y0+xoff);
  51   1        LCD_HL_DrawPixel(x0+yoff,y0-xoff);
  52   1        if (yoff) {
  53   2          LCD_HL_DrawPixel(x0+xoff,y0-yoff);
  54   2          LCD_HL_DrawPixel(x0-xoff,y0-yoff);
C51 COMPILER V8.05a   GUICIRC                                                              04/11/2008 14:18:55 PAGE 2   

  55   2          LCD_HL_DrawPixel(x0-yoff,y0+xoff);
  56   2          LCD_HL_DrawPixel(x0-yoff,y0-xoff);
  57   2        }
  58   1      }
  59          
  60          
  61          void GL_DrawCircle(int x0, int y0, int r) {
  62   1        I32 i;
  63   1        int imax = ((I32)((I32)r*707))/1000+1;
  64   1        I32 sqmax = (I32)r*(I32)r+(I32)r/2;
  65   1        I32 y=r;
  66   1        Draw8Point(x0,y0,r,0);
  67   1        for (i=1; i<= imax; i++) {
  68   2          if ((i*i+y*y) >sqmax) {
  69   3            Draw8Point(x0,y0,i,y);
  70   3            y--;
  71   3          }
  72   2          Draw8Point(x0,y0,i,y);
  73   2        }
  74   1      }
  75          
  76          void GUI_DrawCircle       (int x0, int y0, int r) {
  77   1        #if (GUI_WINSUPPORT)
                  GUI_RECT Rect;
                #endif
  80   1        GUI_LOCK();
  81   1        #if (GUI_WINSUPPORT)
                  WM_ADDORG(x0,y0);
                  Rect.x0 = x0-r;
                  Rect.x1 = x0+r;
                  Rect.y0 = y0-r;
                  Rect.y1 = y0+r;
                  WM_ITERATE_START(&Rect); {
                #endif
  89   1          GL_DrawCircle( x0, y0, r);
  90   1        #if (GUI_WINSUPPORT)
                  } WM_ITERATE_END();
                #endif
  93   1        GUI_UNLOCK();
  94   1      }
  95          
  96          
  97          /*
  98                *************************************************
  99                *                                               *
 100                *            Fill Circle                        *
 101                *                                               *
 102                *************************************************
 103          */
 104          void GL_FillCircle       (int x0, int y0, int r) {
 105   1        I32 i;
 106   1        int imax = ((I32)((I32)r*707))/1000+1;
 107   1        I32 sqmax = (I32)r*(I32)r+(I32)r/2;
 108   1        I32 x=r;
 109   1        LCD_HL_DrawHLine(x0-r,y0,x0+r);
 110   1        for (i=1; i<= imax; i++) {
 111   2          if ((i*i+x*x) >sqmax) {
 112   3            /* draw lines from outside */
 113   3            if (x>imax) {
 114   4              LCD_HL_DrawHLine (x0-i+1,y0+x, x0+i-1);
 115   4              LCD_HL_DrawHLine (x0-i+1,y0-x, x0+i-1);
 116   4            }
C51 COMPILER V8.05a   GUICIRC                                                              04/11/2008 14:18:55 PAGE 3   

 117   3            x--;
 118   3          }
 119   2          /* draw lines from inside (center) */
 120   2          LCD_HL_DrawHLine(x0-x,y0+i, x0+x);
 121   2          LCD_HL_DrawHLine(x0-x,y0-i, x0+x);
 122   2        }
 123   1      }
 124          
 125          void GUI_FillCircle       (int x0, int y0, int r) {
 126   1        GUI_LOCK();
 127   1        #if (GUI_WINSUPPORT)
                  WM_ADDORG(x0,y0);
                  WM_ITERATE_START(NULL); {
                #endif
 131   1        GL_FillCircle(x0,y0,r);
 132   1        #if (GUI_WINSUPPORT)
                  } WM_ITERATE_END();
                #endif
 135   1        GUI_UNLOCK();
 136   1      }
 137          
 138          
 139          
 140          /*
 141                  *********************************************************
 142                  *                                                       *
 143                  *               Ellipse drawing / filling               *
 144                  *                                                       *
 145                  *********************************************************
 146          
 147          The most efficient way to calculate the ellipse positions
 148          is using the knowledge that the ellipse is just circle which has
 149          compressed (or stretched) in one direction. For a circle, the
 150          following equation holds true for all points located on the border of
 151          it:
 152                         x^2 + y(x)^2 = r^2 = const
 153          
 154          Therefor, for an ellipse we can make use of the following equation:
 155          
 156                         (ry*x)^2 + (rx*y(x))^2 = (ry*rx)^2 = const
 157          
 158          */
 159          
 160          void GL_FillEllipse      (int x0, int y0, int rx, int ry) {
 161   1        I32 OutConst, Sum, SumY;
 162   1        int x,y;
 163   1        U32 _rx = rx;
 164   1        U32 _ry = ry;
 165   1        OutConst = _rx*_rx*_ry*_ry  /* Constant as explaint above */
 166   1                  +(_rx*_rx*_ry>>1); /* To compensate for rounding */
 167   1        x = rx;
 168   1        for (y=0; y<=ry; y++) {
 169   2          SumY =((I32)(rx*rx))*((I32)(y*y)); /* Does not change in loop */
 170   2          while (Sum = SumY + ((I32)(ry*ry))*((I32)(x*x)),
 171   2                 (x>0) && (Sum>OutConst))
 172   2          {
 173   3            x--;
 174   3          }
 175   2          LCD_HL_DrawHLine(x0-x, y0+y, x0+x);
 176   2          if (y)
 177   2            LCD_HL_DrawHLine(x0-x, y0-y, x0+x);
 178   2        }
C51 COMPILER V8.05a   GUICIRC                                                              04/11/2008 14:18:55 PAGE 4   

 179   1      }
 180          
 181          void GUI_FillEllipse      (int x0, int y0, int rx, int ry) {
 182   1        #if (GUI_WINSUPPORT)
                  GUI_RECT r;
                #endif
 185   1        GUI_LOCK();
 186   1        #if (GUI_WINSUPPORT)
                  WM_ADDORG(x0,y0);
                  /* Calc rectangle in order to avoid unnecessary drawing ops. */
                  r.x0 = x0-rx; r.x1 = x0+rx; r.y0 = y0-ry; r.y1 = y0+ry;
                  WM_ITERATE_START(&r); {
                #endif
 192   1        GL_FillEllipse (x0,y0, rx, ry);
 193   1        #if (GUI_WINSUPPORT)
                  } WM_ITERATE_END();
                #endif
 196   1        GUI_UNLOCK();
 197   1      }
 198          
 199          void GL_DrawEllipse      (int x0, int y0, int rx, int ry) {
 200   1        I32 OutConst, Sum, SumY;
 201   1        int x,y;
 202   1        int xOld;
 203   1        U32 _rx = rx;
 204   1        U32 _ry = ry;
 205   1        OutConst = _rx*_rx*_ry*_ry  /* Constant as explaint above */
 206   1                  +(_rx*_rx*_ry>>1); /* To compensate for rounding */
 207   1        xOld = x = rx;
 208   1        for (y=0; y<=ry; y++) {
 209   2          if (y==ry) {
 210   3            x=0;
 211   3          } else {
 212   3            SumY =((I32)(rx*rx))*((I32)(y*y)); /* Does not change in loop */
 213   3            while (Sum = SumY + ((I32)(ry*ry))*((I32)(x*x)),
 214   3                   (x>0) && (Sum>OutConst)) x--;
 215   3          }
 216   2      /* Since we draw lines, we can not draw on the first
 217   2          iteration
 218   2      */
 219   2          if (y) {
 220   3            GL_DrawLine1(x0-xOld,y0-y+1,x0-x,y0-y);
 221   3            GL_DrawLine1(x0-xOld,y0+y-1,x0-x,y0+y);
 222   3            GL_DrawLine1(x0+xOld,y0-y+1,x0+x,y0-y);
 223   3            GL_DrawLine1(x0+xOld,y0+y-1,x0+x,y0+y);
 224   3          }
 225   2          xOld = x;
 226   2        }
 227   1      }
 228          
 229          void GUI_DrawEllipse      (int x0, int y0, int rx, int ry) {
 230   1        #if (GUI_WINSUPPORT)
                  GUI_RECT r;
                #endif
 233   1        GUI_LOCK();
 234   1        #if (GUI_WINSUPPORT)
                  WM_ADDORG(x0,y0);
                /* Calc rectangle in order to avoid unnecessary drawing ops. */
                  r.x0 = x0-rx; r.x1 = x0+rx; r.y0 = y0-ry; r.y1 = y0+ry;
                  WM_ITERATE_START(&r); {
                #endif
 240   1        GL_DrawEllipse(x0, y0, rx, ry);
C51 COMPILER V8.05a   GUICIRC                                                              04/11/2008 14:18:55 PAGE 5   

 241   1        #if (GUI_WINSUPPORT)
                  } WM_ITERATE_END();
                #endif
 244   1        GUI_UNLOCK();
 245   1      }
 246          
 247          
 248          
 249          
 250          
 251          
 252          
 253          
 254          
 255          
 256          
 257          
 258          
 259          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =   3277    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----     130
   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 + -