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

    ---

  • 相关阅读:
    poj 1269(两条直线交点)
    poj 2398(叉积判断点在线段的哪一侧)
    poj 2318(叉积判断点在线段的哪一侧)
    HDU 5650 so easy
    POJ 1328 Radar Installation
    POJ 1017 Packets
    POJ 3190 Stall Reservations
    CodeForces 652A Gabriel and Caterpillar
    CodeForces 652B z-sort
    CodeForces 652C Foe Pairs
  • 原文地址:https://www.cnblogs.com/Ph-one/p/7007537.html
Copyright © 2011-2022 走看看