📄 graphics.c
字号:
//#include "graphics/graphics.h"
#define PUBLIC
#define PRIVATE static
double fabs(double x)
{
return x < 0 ? -x : x;
}
/*
SetPixel:画点函数
*/
//PUBLIC void SetPixel(int x,int y,int color)
//{
//}
/*
GetPixel:取得像素点的颜色值
*/
PUBLIC int GetPixel(int x,int y)
{
}
/*
Clear:清屏函数
*/
PUBLIC void Clear()
{
}
/*
Line:画线函数
*/
PUBLIC void Line(int x1,int y1,int x2,int y2,int color)
{
int i;
float dx,dy,length,x,y;
if(fabs(x2-x1)>=fabs(y2-y1))
length=(float)fabs(x2-x1);
else
length=(float)fabs(y2-y1);
dx=(x2-x1)/length;
dy=(y2-y1)/length;
i=1;
x=(float)x1;
y=(float)y1;
while(i<=length)
{
SetPixel((int)(x+0.5),(int)(y+0.5),color);
x=x+dx;
y=y+dy;
i++;
}
}
/*
MoveTo:置开始画线位置
*/
PUBLIC void MoveTo(int x,int y)
{
}
/*
LineTo:在画线开始点和给定点之间画直线
*/
PUBLIC void LineTo(int x,int y)
{
}
/*
Rectangle:画正方形
*/
PUBLIC void Rectangle(int x1,int y1,int x2,int y2,int color )
{
}
/*
Poly:画多边形
*/
PUBLIC void Poly(int *border,int color)
{
}
/*
Circle:画圆
*/
/********************************Circle**************************************************/
PRIVATE void CirclePoints(int x,int y,int color)
{
SetPixel(x,y,color);SetPixel(y,x,color);
SetPixel(-x,y,color);SetPixel(y,-x,color);
SetPixel(x,-y,color);SetPixel(-y,x,color);
SetPixel(-x,-y,color);SetPixel(-y,-x,color);
}
PUBLIC void Circle(int x0,int y0,int r,int color)
{
int x,y;
int e;
x=0;y=r;e=1-r;
CirclePoints(x,y,color);
while(x<=y)
{
if(e<0)
e+=2*x+3;
else
{
e+=2*(x-y)+5;
y--;
}
x++;
CirclePoints(x,y,color);
}
}
/********************************Circle**************************************************/
/*
Sector:画扇形
*/
PUBLIC void Sector(int x0,int y0,int r,int startAngle,int endAngle,int color)
{
}
/*
Ellipse:画椭圆
*/
PUBLIC void Ellipse(int x0,int y0,long r1,long r2,int color)
{
}
/*
Rectangle:画实正方形
*/
PUBLIC void FillRectangle(int x1,int y1,int x2,int y2,int color )
{
}
/*
Poly:画实多边形
*/
PUBLIC void FillPoly(int *border,int color)
{
}
/*
Circle:画实圆
*/
PUBLIC void FillCircle(int x0,int y0,int r,int color)
{
}
/*
Sector:画实扇形
*/
PUBLIC void FillSector(int x0,int y0,int r,int startAngle,int endAngle,int color)
{
}
/*
Ellipse:画实椭圆
*/
PUBLIC void FillEllipse(int x0,int y0,long r1,long r2,int color)
{
}
/*
PutImage:
*/
PUBLIC void PutImage(unsigned char *image,int x1,int y1,int x2,int y2)
{
}
/*
GetImage:
*/
PUBLIC void GetImage(unsigned char *image,int x1,int y1,int x2,int y2)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -