Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Parth1906
GitHub Repository: Parth1906/SPPU-2019-Pattern-SE-COMP-Computer-Graphics-Practicals
Path: blob/main/10. Sunrise and Sunset.cpp
724 views
1
#include<iostream>
2
#include<graphics.h>
3
#include<cstdlib>
4
#include<dos.h>
5
#include<cmath>
6
using namespace std;
7
8
int main()
9
{
10
initwindow(800,500);
11
int x0,y0;
12
int gdriver = DETECT,gmode,errorcode;
13
int xmax,ymax;
14
15
errorcode=graphresult();
16
17
if(errorcode!=0)
18
{
19
cout<<"Graphics error:"<<grapherrormsg(errorcode);
20
cout<<"Press any ket to halt";
21
exit(1);
22
}
23
int i,j;
24
setbkcolor(BLUE);
25
setcolor(RED);
26
rectangle(0,0,getmaxx(),getmaxy());
27
28
outtextxy(250,240,"::::PRESS ANY KEY TO CONTINUE:::::");
29
while(!kbhit());
30
for(i=50,j=0;i<=250,j<=250;i+=5,j+=5)
31
{
32
delay(120);
33
cleardevice();
34
if(i<=150)
35
{
36
setcolor(YELLOW);
37
setfillstyle(1,YELLOW);
38
fillellipse(i,300-j,20,20);
39
}
40
else
41
{
42
setcolor(GREEN^RED);
43
setfillstyle(1,GREEN^RED);
44
fillellipse(i,300-j,20,20);
45
}
46
}
47
delay(1000);
48
cleardevice();
49
setcolor(RED);
50
setfillstyle(1,RED);
51
fillellipse(300,50,20,20);
52
delay(150);
53
54
int k,l;
55
for(k=305,l=55;k<=550,l<=300;k+=5,l+=5)
56
{
57
delay(120);
58
cleardevice();
59
if(k<=450)
60
{
61
62
setcolor(GREEN^RED);
63
setfillstyle(1,GREEN^RED);
64
65
fillellipse(k,l,20,20);
66
}
67
else
68
{
69
setcolor(YELLOW);
70
setfillstyle(1,YELLOW);
71
fillellipse(k,l,20,20);
72
}
73
}
74
return 0;
75
}
76
77