圆角函数

-------

#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);
    ¦   }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

---

posted @ 2017-06-14 10:31  瘋耔  阅读(219)  评论(0编辑  收藏  举报
跳至侧栏