C S C O R N E R

Drawing circle & ellipse using graphics lib in C++

Objective
The objective of this assignment is to;
  • Learn and practice basic concepts of computer graphics using Dev-C++.
  • Learn to draw circle and ellipse using graphics library functions.
Task
Task is to draw two ellipses and one circle having the same center. These three shapes i.e. One circle and two ellipses should be concentric. You can select any color for drawing these three shapes.
Solution
#include 
#include 
#include 
#include 
 
int main()
{
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"");
setcolor(WHITE);
 
settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
outtextxy(10, 10, "Welcome to Graphics Programming");
outtextxy(10, 30, "My VU-ID is BC110200816");
line(0,60,getmaxx(),60);
 
int i,cir_x,cir_y;
cir_x=getmaxx()/2;
cir_y=getmaxy()/2;
 
setcolor(WHITE);
circle(400,200,120);
 
ellipse(400,200,0,360,120,50);
 
setcolor(RED);
ellipse(400,200,0,360,50,120);
 
getch();
}

Screenshot

No comments:

Powered by Blogger.