分享
 
 
 

一个简单的玫瑰花程序(二)

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

一个简单的玫瑰花程序(二)

这个玫瑰花的程序我在3月28日就发过了,可是问题不少,在这个语句(arc(x+64,y-57,300,490,17);)中出现了颜色外泻,请注重,终止角是490度,而不是460度,不过还没有写完,大家可以凭自己的爱好添家或删除其中的语句,绘出更漂亮的图形。谢谢合作!

作者:张某 地址:云南农叶大学

修改后的程序如下:

#include <stdio.h>

#include <dos.h>

#include <graphics.h>

#include <math.h>

#define FNX(x) (int)(xo+(x)*1.0)

#define FNY(y) (int)(getmaxy()-(yo+(y)*1.0))

#define FNX2(phi) cos(phi)*ac-sin(phi)*bs

#define FNY2(phi) cos(phi)*as+sin(phi)*bc

/*画旋转的椭圆*/

void elli(int xo,int yo,int a,int b,double theta)

{

int i;

double da,c,s,ac,as,bc,bs,xf,yf,phi,x,y;

theta=theta*0.01745;

da=3*0.1745;

c=cos(theta);s=sin(theta);

ac=a*c;as=a*s;bc=b*c;bs=b*s;

x=FNX2(0);y=FNY2(0);

moveto(FNX(x),FNY(y));

for(i=1;i<=360;i++)

{

phi=i*da;xf=x*cos(phi)*0.1;yf=b*sin(phi)*0.1;

x=FNX2(phi);y=FNY2(phi);

lineto(FNX(x),FNY(y));

}

}

/*花*/

void hua(int x,int y)

{

register i;

/*画粉红色玫瑰*/

setcolor(12);

arc(x+65,y-60,150,350,8);

arc(x+66,y-54,300,470,8);

arc(x+65,y-56,30,230,10);

arc(x+64,y-57,300,490,17);

ellipse(x+73,y-30,250,450,27,40);

ellipse(x+59,y-30,100,290,27,40);

ellipse(x+65,y-40,140,270,20,30);

setfillstyle(SOLID_FILL,5);

floodfill(x+65,y-20,12);

/*画红色玫瑰*/

arc(x,y,150,350,12);

arc(x+1,y+8,280,470,12);

arc(x,y+2,30,230,16);

arc(x,y+3,80,240,28);

arc(x+2,y+8,180,330,22);

arc(x-2,y+2,310,460,25);

ellipse(x-12,y+30,120,300,30,40);

ellipse(x+10,y+28,250,423,30,42);

ellipse(x-4,y+10,290,393,30,40);

setfillstyle(SOLID_FILL,4);

floodfill(x+5,y+31,12);

/*画紫色花骨朵*/

ellipse(x+120,y+5,0,360,15,25);

setfillstyle(SOLID_FILL,1);

floodfill(x+120,y,12);

/*画黄色花骨朵*/

ellipse(x-70,y+10,0,360,14,20);

setfillstyle(SOLID_FILL,14);

floodfill(x-70,y+10,12);

setcolor(10);

/*画红花花萼*/

ellipse(x-15,y+32,190,310,30,35);

ellipse(x+16,y+32,235,355,26,35);

ellipse(x,y+35,190,350,43,50);

arc(x,y+82,190,350,6);

setfillstyle(SOLID_FILL,2);

floodfill(x,y+75,10);

/*画粉花花萼*/

ellipse(x+50,y-48,190,320,22,50);

ellipse(x+80,y-48,220,350,22,50);

ellipse(x+65,y-28,180,360,36,50);

floodfill(x+65,y+18,10);

/*画主枝*/

for(i=0;i<3;i++)

{

ellipse(x-98,y+100+i,255,371,100,80);

ellipse(x-20,y+30+i,260,358,140,140);

ellipse(x+224,y+20+i,180,218,160,140);

}

/*画侧枝*/

ellipse(x+70,y+34,180,233,140,140);

ellipse(x,y+40,205,255,100,120);

ellipse(x+135,y-30,209,249,72,120);

ellipse(x,y+20,263,301,100,120);

ellipse(x+85,y-10,278,305,100,120);

ellipse(x+100,y-62,282,308,90,120);

ellipse(x-50,y-10,277,314,30,120);

ellipse(x+70,y+80,222,266,52,120);

ellipse(x-60,y-45,229,266,52,120);

ellipse(x+79,y-45,229,266,52,120);

ellipse(x+84,y,224,273,52,120);

ellipse(x+110,y+40,240,282,100,120);

/*画紫花骨朵花萼*/

ellipse(x+120,y-6,200,340,17,25);

ellipse(x+120,y+7,160,380,17,27);

floodfill(x+122,y+30,10);

/*画黄花骨朵花萼*/

ellipse(x-70,y+15,140,390,17,20);

ellipse(x-75,y-10,205,340,10,30);

ellipse(x-60,y-10,195,340,5,30);

floodfill(x-70,y+32,10);

/*画叶*/

/*画右边的叶子*/

elli(x+168,y+282,10,20,-40);

elli(x+160,y+252,8,16,260);

elli(x+145,y+270,8,16,-15);

elli(x+156,y+224,10,20,-45);

elli(x+150,y+200,8,16,270);

elli(x+135,y+220,8,16,-10);

elli(x+146,y+144,8,16,-80);

elli(x+130,y+130,6,12,235);

elli(x+125,y+154,7,14,-10);

elli(x+78,y+98,6,12,-90);

elli(x+60,y+90,5,10,180);

elli(x+70,y+109,5,10,-45);

/*画左边的叶子*/

elli(x-125,y+270,12,24,60);

elli(x-95,y+270,10,20,10);

elli(x-110,y+245,10,20,90);

elli(x-105,y+220,10,20,45);

elli(x-100,y+190,8,16,135);

elli(x-75,y+210,8,16,-45);

/*画中间的叶子*/

elli(x+65,y+190,10,20,-45);

elli(x+40,y+185,8,16,0);

elli(x+55,y+165,8,16,90);

}

/*主程序*/

main()

{

int driver=VGA,mode=VGAHI;

initgraph(&driver,&mode,"C:\TC");

cleardevice();

hua(450,90);

setcolor(10);

rectangle(0,0,639,479);

getch();

closegraph();

}

修改了的程序如下:

#include <stdio.h>

#include <dos.h>

#include <graphics.h>

#include <math.h>

#define FNX(x) (int)(xo+(x)*1.0)

#define FNY(y) (int)(getmaxy()-(yo+(y)*1.0))

#define FNX2(phi) cos(phi)*ac-sin(phi)*bs

#define FNY2(phi) cos(phi)*as+sin(phi)*bc

/*画旋转的椭圆*/

void elli(int xo,int yo,int a,int b,double theta)

{

int i;

double da,c,s,ac,as,bc,bs,xf,yf,phi,x,y;

theta=theta*0.01745;

da=3*0.1745;

c=cos(theta);s=sin(theta);

ac=a*c;as=a*s;bc=b*c;bs=b*s;

x=FNX2(0);y=FNY2(0);

moveto(FNX(x),FNY(y));

for(i=1;i<=360;i++)

{

phi=i*da;xf=x*cos(phi)*0.1;yf=b*sin(phi)*0.1;

x=FNX2(phi);y=FNY2(phi);

lineto(FNX(x),FNY(y));

}

}

/*花*/

void hua(int x,int y)

{

register i;

/*画粉红色玫瑰*/

setcolor(12);

arc(x+65,y-60,150,350,8);

arc(x+66,y-54,300,470,8);

arc(x+65,y-56,30,230,10);

arc(x+64,y-57,300,490,17);

ellipse(x+73,y-30,250,450,27,40);

ellipse(x+59,y-30,100,290,27,40);

ellipse(x+65,y-40,140,270,20,30);

setfillstyle(SOLID_FILL,5);

floodfill(x+65,y-20,12);

/*画红色玫瑰*/

arc(x,y,150,350,12);

arc(x+1,y+8,280,470,12);

arc(x,y+2,30,230,16);

arc(x,y+3,80,240,28);

arc(x+2,y+8,180,330,22);

arc(x-2,y+2,310,460,25);

ellipse(x-12,y+30,120,300,30,40);

ellipse(x+10,y+28,250,423,30,42);

ellipse(x-4,y+10,290,393,30,40);

setfillstyle(SOLID_FILL,4);

floodfill(x+5,y+31,12);

/*画紫色花骨朵*/

ellipse(x+120,y+5,0,360,15,25);

setfillstyle(SOLID_FILL,1);

floodfill(x+120,y,12);

/*画黄色花骨朵*/

ellipse(x-70,y+10,0,360,14,20);

setfillstyle(SOLID_FILL,14);

floodfill(x-70,y+10,12);

setcolor(10);

/*画红花花萼*/

ellipse(x-15,y+32,190,310,30,35);

ellipse(x+16,y+32,235,355,26,35);

ellipse(x,y+35,190,350,43,50);

arc(x,y+82,190,350,6);

setfillstyle(SOLID_FILL,2);

floodfill(x,y+75,10);

/*画粉花花萼*/

ellipse(x+50,y-48,190,320,22,50);

ellipse(x+80,y-48,220,350,22,50);

ellipse(x+65,y-28,180,360,36,50);

floodfill(x+65,y+18,10);

/*画主枝*/

for(i=0;i<3;i++)

{

ellipse(x-98,y+100+i,255,371,100,80);

ellipse(x-20,y+30+i,260,358,140,140);

ellipse(x+224,y+20+i,180,218,160,140);

}

/*画侧枝*/

ellipse(x+70,y+34,180,233,140,140);

ellipse(x,y+40,205,255,100,120);

ellipse(x+135,y-30,209,249,72,120);

ellipse(x,y+20,263,301,100,120);

ellipse(x+85,y-10,278,305,100,120);

ellipse(x+100,y-62,282,308,90,120);

ellipse(x-50,y-10,277,314,30,120);

ellipse(x+70,y+80,222,266,52,120);

ellipse(x-60,y-45,229,266,52,120);

ellipse(x+79,y-45,229,266,52,120);

ellipse(x+84,y,224,273,52,120);

ellipse(x+110,y+40,240,282,100,120);

/*画紫花骨朵花萼*/

ellipse(x+120,y-6,200,340,17,25);

ellipse(x+120,y+7,160,380,17,27);

floodfill(x+122,y+30,10);

/*画黄花骨朵花萼*/

ellipse(x-70,y+15,140,390,17,20);

ellipse(x-75,y-10,205,340,10,30);

ellipse(x-60,y-10,195,340,5,30);

floodfill(x-70,y+32,10);

/*画叶*/

/*画右边的叶子*/

elli(x+168,y+282,10,20,-40);

elli(x+160,y+252,8,16,260);

elli(x+145,y+270,8,16,-15);

elli(x+156,y+224,10,20,-45);

elli(x+150,y+200,8,16,270);

elli(x+135,y+220,8,16,-10);

elli(x+146,y+144,8,16,-80);

elli(x+130,y+130,6,12,235);

elli(x+125,y+154,7,14,-10);

elli(x+78,y+98,6,12,-90);

elli(x+60,y+90,5,10,180);

elli(x+70,y+109,5,10,-45);

/*画左边的叶子*/

elli(x-125,y+270,12,24,60);

elli(x-95,y+270,10,20,10);

elli(x-110,y+245,10,20,90);

elli(x-105,y+220,10,20,45);

elli(x-100,y+190,8,16,135);

elli(x-75,y+210,8,16,-45);

/*画中间的叶子*/

elli(x+65,y+190,10,20,-45);

elli(x+40,y+185,8,16,0);

elli(x+55,y+165,8,16,90);

}

/*主程序*/

main()

{

int driver=VGA,mode=VGAHI;

initgraph(&driver,&mode,"C:\TC");

cleardevice();

hua(450,90);

setcolor(10);

rectangle(0,0,639,479);

getch();

closegraph();

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有