C language to achieve the rose flower

Source: Internet
Author: User
Tags cos sin

1. #include <dos.h>

2. #include <graphics.h>

3. #include <math.h>

4./* Roses * *

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

6. #define FNY (y) (int) (Getmaxy ()-(yo+ (y) *1.0))

7. #define FNX2 (PHI) cos (PHI) *ac-sin (PHI) *bs

8. #define FNY2 (PHI) cos (PHI) *as+sin (PHI) *BC

9.

10./* to draw a rotating ellipse * *

11.void Elli (int xo,int yo,int a,int b,double Theta)

12.{

13.int i;

14.double Da,c,s,ac,as,bc,bs,xf,yf,phi,x,y;

15.theta=theta*0.01745;

16.da=3*0.1745;

17.c=cos (theta); S=sin (theta);

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

19.X=FNX2 (0); y=fny2 (0);

20.moveto (FNX (x), Fny (y));

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

22.{

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

24.x=fnx2 (PHI); Y=fny2 (PHI);

25.lineto (FNX (x), Fny (y));

26.}

27.}

28.

29./* Flower * *

30.void hua (int x,int y)

31.{

32.register i;

33./* Painted Pink Roses * *

34.setcolor (12);

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

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

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

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

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

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

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

42.setfillstyle (solid_fill,5);

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

44./* Painted Red roses * *

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

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

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

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

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

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

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

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

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

54.setfillstyle (solid_fill,4);

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

56./* Painted purple flowers

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

58.setfillstyle (solid_fill,1);

59.floodfill (x+120,y,12);

60./* PAINTED YELLOW huaguduo * *

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

62.setfillstyle (solid_fill,14);

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

64.setcolor (10);

65./* painted safflower calyx * *

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

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

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

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

70.setfillstyle (solid_fill,2);

71.floodfill (x,y+75,10);

72./* to draw calyx with pink flowers * *

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

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

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

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

77./* Painting Primary Branch * *

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

79.{

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

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

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

83.}

84./* Draw Lateral Branches * *

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

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

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

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

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

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.