图形图象课程设计

来源:百度知道 编辑:UC知道 时间:2024/06/15 20:26:27
c语言课程图形处理程序,要求用C语言编辑一个图形的程序,还要能任意改变它的形状,大小,颜色等

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
#define PAI 3.1415926

void main()
{
int gdriver=DETECT,gmode,i;
char str1[]="x",str2[]="y",str3[]="0",c=227;
float x1,y1,m,x2,y2;

registerbgidriver(EGAVGA_driver);
initgraph( &gdriver, &gmode,"");

setbkcolor(0);
setcolor(15);

line(150,180,150,360);
line(100,300,400,300);
line(150,180,145,190);
line(150,180,155,190);
line(400,300,390,305);
line(400,300,390,295);

settextstyle(1,0,10);
setcolor(2);

outtextxy(390,310,str1);
outtextxy(130,190,str2);
outtextxy(130,310,str3);

x1=150;
y1=300;
setcolor(4);

for(i=0;i<=360;i++)
{
m=i/360.0*(2*PAI);
x2=150+m*30;
y2=300-sin(m)*30; /*坐标值都放大30倍,不然图太小*/