当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C语言 pieslice()用法及代码示例


pieslice()绘制并填充中心为(x,y)且给定半径为r的饼图。切片从s_angle到e_angle,它们是饼图切片的开始角度和结束角度。扇形的角度以度为单位,并逆时针测量。

用法:

void pieslice(int x, int y, int s_angle, 
                    int e_angle, int r);

where,
(x, y) is center of the circle.
r is the radius of the circle.
s_angle and e_angle are the starting 
and ending angles respectively.

例子:


Input:x = 300, y = 300, s_angle = 0 ,
        e_angle = 120, r = 150
Output:

Input:x = 300, y = 300, s_angle = 30 ,
        e_angle = 100, r = 200
Output:

下面是pieslice()函数的实现:

// C Implementation for drawing pieslice 
#include <graphics.h> 
  
// driver code 
int main() 
{ 
    // gm is Graphics mode which  
    // is a computer display mode  
    // that generates image using pixels. 
    // DETECT is a macro defined in 
    // "graphics.h" header file 
    int gd = DETECT, gm; 
  
    // initgraph initializes the  
    // graphics system by loading a  
    // graphics driver from disk 
    initgraph(&gd, &gm, ""); 
  
    // pieslice function 
    pieslice(300, 300, 0, 120, 150); 
  
    getch(); 
  
    // closegraph function closes the  
    // graphics mode and deallocates all  
    // memory allocated by graphics system . 
    closegraph(); 
  
    return 0; 
}

输出:




相关用法


注:本文由纯净天空筛选整理自Sahil_Bansall大神的英文原创作品 pieslice() function in C。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。