如何使用Visual Studio 2005画一张正规的国旗图片

在这里插入图片描述如何使用Visual Studio 2005画一张正规的国旗图片
绘画一张正规标准的国旗图片是学习C程序最基础的一步,也是必不可少的一步,在学习C程序的第一天,学习绘画国旗是十分必要的,接下来,我将展示出它的绘画过程以及成品图。

#include <graphics.h>      // 引用图形库头文件
#include <conio.h>
#include<math.h>
const double PI = 3.1415927;

void DrawStar(int x, int y, int R, double arcbegin)
{
	POINT pt[10];
	double r = R*sin(18 * PI / 180) / sin(126 * PI / 180);
	double arc = PI / 5.0;

	double r1;


	for (int i = 0; i < 10; ++i)
	{
		if (i % 2 == 0)
			r1 = R;
		else
			r1 = r;
		pt[i].y = sin(arcbegin + i*arc)*r1 + y;
		pt[i].x = cos(arcbegin + i*arc)*r1 + x;


	}
	setfillcolor(RGB(255,255,0));
	setcolor(RGB(255,255,0));
	fillpolygon(pt, 10);



}

int main()
{
	initgraph(900, 600);   // 创建绘图窗口
	setlinecolor(RGB(255, 0, 0));
	setfillcolor(RGB(255, 0, 0));
	fillrectangle(0, 0, 900, 600);


	DrawStar(150, 150, 90, -PI / 2);
	DrawStar(300, 60, 30, -PI - atan(3.0 / 5));
	DrawStar(360, 120, 30, -PI - atan(1.0 / 7));
	DrawStar(360, 210, 30, -PI + atan(2.0 / 7));
	DrawStar(300, 270, 30, -PI + atan(4.0 / 5));



	_getch();              // 按任意键继续
	closegraph();          // 关闭绘图窗口
}
以上就是我绘制国旗的程序以及成果图。

我爱中国嗷!

  • 2
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值