C语言,easyx,fill描边和填充,绘制一个描边为绿色填充为红色的圆。

本文介绍了如何在C语言中利用EasyX图形库创建一个800x600窗口,通过设置坐标系、颜色和图形操作,实现在屏幕上绘制一个绿色描边、红色填充的圆形,并暂停程序等待用户按键关闭窗口。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include<stdio.h>

#include<easyx.h>//图形库头文件

int main()

{

 initgraph(800,600);//创建一个窗口,宽度为800,高度为600

 setorigin(400, 300);//以物理坐标为基准设置逻辑坐标的原点

 setaspectratio(1, -1);//实现坐标轴的翻转,-1把y轴翻转

 setlinecolor(GREEN);//设置描边为绿色

 setfillcolor(RED);//填充图形颜色为红色

 fillcircle(0, 0, 100);//fill描边和填充图形

 getchar();//暂时阻塞程序,等待用户按键关闭

 closegraph();//关闭绘图窗体函数

 return 0;

}

fill描边和填充,绘制一个描边为绿色填充为红色的圆

 

 

#include "stdio.h" #include "conio.h" #include "math.h" #include "graphics.h" #include "stdlib.h" #include "time.h" int main() { int graphdriver=DETECT,graphmode; /*自动搜索显示器类型显示模式*/ int r; int i,j,n,k,d; float x,y,q; int a[100],b[100]; char str1[80],str2[80]; printf("please input the numbers in order r--zheng jie yuan ban jing\n"); scanf("%d",&r); printf("please input the numbers in order n--duo bian xing de bian shu\n"); scanf("%d",&n); printf("please input the numbers in order k--duo bian xing de ge shu\n"); scanf("%d",&k); printf("please input the numbers in order d--bian de fen ge yin zi!\n"); scanf("%d",&d); initgraph(&graphdriver,&graphmode,"D:\\TC"); /*初始化图形系统*/ printf("\n\tnotice:maxx=%d,maxy=%d\n",getmaxx(),getmaxy()); printf("\n\tplease input the numbers in order r,n,k,d:\n"); printf("\n\tr=%d, n=%d, k=%d, d=%d",r,n,k,d); x=(getmaxx()+1)/2.0; y=(getmaxy()+1)/2.0; q=360/n; /*角增量*/ q=q*3.1415926/180; /*将角增量化为弧度*/ for(i=1;i<=n;i++) /*计算初始正n角形顶点坐标*/ { a[i]=(int)((int)x+r*cos((i-1)*q)); b[i]=(int)((int)y-r*sin((i-1)*q)); } a[n+1]=a[1]; b[n+1]=b[1]; /*闭合正n角形,以便连续线*/ /*--------k个正多角形-----------*/ for(i=1;i<=k;i++) { for(j=1;j<=n;j++) /*一个正多角形*/ line(a[j],b[j],a[j+1],b[j+1]); for(j=1;j<=n;j++) /*计算下一个正多边形顶点坐标*/ { a[j]=(int)(a[j]+(a[j+1]-a[j])/d); b[j]=(int)(b[j]+(b[j+1]-b[j])/d); } a[n+1]=a[1]; b[n+1]=b[1]; } setcolor(4); settextstyle(TRIPLEX_FONT,HORIZ_DIR,1); sprintf(str1,"%s","---- shuxuexi: hugang---time:2004.4.8----"); sprintf(str2,"%s","--graphics: duo bian xing de zhu ci xuan zhuang--"); outtextxy(115,410,str1); outtextxy(90,430,str2); getch(); closegraph(); }
最新发布
03-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值