zoukankan      html  css  js  c++  java
  • 圆角函数

    -------

    #define BITS_PER_LONG 32
    
    unsigned long int_sqrt(unsigned long x)  
    {  
        unsigned long op, res, one;  
        op = x;  
        res = 0;  
        one = 1UL << (BITS_PER_LONG - 2);  
        while (one > op)  
        ¦   one >>= 2;  
      
        while (one != 0) {  
        ¦   ¦  if (op >= res + one) {  
        ¦   ¦   ¦   ¦   ¦ op = op - (res + one);  
        ¦   ¦   ¦   ¦   ¦ res = res +  2 * one;  
        ¦   ¦   ¦   ¦  }  
        ¦   ¦  res /= 2;  
        ¦   ¦  one /= 4;  
        ¦   }  
        return res;  
    } 

        ¦   {
        ¦   ¦   int left_top_x, left_top_y, right_bot_x, right_bot_y;
        ¦   ¦   int i;
        ¦   ¦   int radius = CFG_DISPLAY_WIDTH/10;
    //            for(i = 0; i < radius; i++)
    //            {
    //                left_top_x = 0;
    //                left_top_y = i;
    //                right_bot_x = radius - i;
    //                right_bot_y = i+1;
    //                mt_disp_fill_rect(left_top_x, left_top_y, right_bot_x, right_bot_y, 0xFFFF0000);
    //            }
        ¦   ¦   for(i = 0; i < radius; i++)
        ¦   ¦   {
        ¦   ¦   ¦   left_top_x = 0;
        ¦   ¦   ¦   left_top_y = i;
        ¦   ¦   ¦   right_bot_x = (int)( radius - int_sqrt(radius*radius - (radius - i)*(radius - i) ) );
        ¦   ¦   ¦   right_bot_y = i+1;
        ¦   ¦   ¦   mt_disp_fill_rect(left_top_x, left_top_y, right_bot_x, right_bot_y, 0xFFFF0000);
        ¦   ¦   }
    
    //            left_top_x = CFG_DISPLAY_WIDTH/3;
    //            left_top_y = 2*CFG_DISPLAY_HEIGHT/3;
    //            right_bot_x = CFG_DISPLAY_WIDTH/2;
    //            right_bot_y = CFG_DISPLAY_HEIGHT;
    //
    
    
    //            mt_disp_fill_rect(left_top_x, left_top_y, right_bot_x, right_bot_y, 0xFFFF0000);
        ¦   }

    ---

  • 相关阅读:
    shell命令--stat
    英文段子
    OCP读书笔记(16)
    shell命令--uptime
    OCP读书笔记(15)
    shell命令--dmesg
    OCP读书笔记(14)
    shell命令--hostname
    OCP读书笔记(13)
    shell命令--uname
  • 原文地址:https://www.cnblogs.com/Ph-one/p/7007537.html
Copyright © 2011-2022 走看看