一个最优美的图案

简介: 【6月更文挑战第30天】一个最优美的图案。

题目:一个最优美的图案(在TC中实现)。

include "graphics.h"

include "math.h"

include "dos.h"

include "conio.h"

include "stdlib.h"

include "stdio.h"

include "stdarg.h"

define MAXPTS 15

define PI 3.1415926

struct PTS {
int x,y;
};
double AspectRatio=0.85;
void LineToDemo(void)
{
struct viewporttype vp;
struct PTS points[MAXPTS];
int i, j, h, w, xcenter, ycenter;
int radius, angle, step;
double rads;
printf(" MoveTo / LineTo Demonstration" );
getviewsettings( &vp );
h = vp.bottom - vp.top;
w = vp.right - vp.left;
xcenter = w / 2; / Determine the center of circle /
ycenter = h / 2;
radius = (h - 30) / (AspectRatio 2);
step = 360 / MAXPTS; /
Determine # of increments /
angle = 0; /
Begin at zero degrees /
for( i=0 ; i<MAXPTS ; ++i ){ /
Determine circle intercepts /
rads = (double)angle
PI / 180.0; / Convert angle to radians /
points[i].x = xcenter + (int)( cos(rads) radius );
points[i].y = ycenter - (int)( sin(rads)
radius AspectRatio );
angle += step; /
Move to next increment /
}
circle( xcenter, ycenter, radius ); /
Draw bounding circle /
for( i=0 ; i<MAXPTS ; ++i ){ /
Draw the cords to the circle /
for( j=i ; j<MAXPTS ; ++j ){ /
For each remaining intersect /
moveto(points[i].x, points[i].y); /
Move to beginning of cord /
lineto(points[j].x, points[j].y); /
Draw the cord */
}
}
}
int main()
{
int driver,mode;
driver=CGA;mode=CGAC0;
initgraph(&driver,&mode,"");
setcolor(3);
setbkcolor(GREEN);
LineToDemo();
}

目录
相关文章
|
2月前
一个最优美的图案
一个最优美的图案。
217 58
|
2月前
|
数据可视化 定位技术 开发者
黑白或彩色线稿地图设计定制装饰画中线条轮廓素材底图获取方法合集
黑白或彩色线稿地图设计定制装饰画中线条轮廓素材底图获取方法合集
|
8月前
颜色拾取器
颜色拾取器
34 0
|
11月前
|
编译器 Windows
<1>[QTCN]颜色拾取器
桌面置顶 获取全局鼠标坐标和颜色(Web值、RGB) 新增: 按下鼠标右键停止/开启
74 1
牛客网——空心正方形图案
牛客网——空心正方形图案
96 0