Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 26

S. No.

Topic Signature
1. WAP to draw a Star in Computer
Graphics;

2. WAP to draw a Computer in Computer


Graphics;

3. WAP to draw a Smiley in Computer


Graphics;

4. WAP to draw a Alphabet in Computer


Graphics;

5. WAP to draw a Joker in Computer


Graphics;

6. WAP to draw a Flag in Computer


Graphics;

7. WAP to draw a Kite in Computer


Graphics;

8. WAP to draw a HUT in Computer


Graphics;

9. WAP to draw a Line in Computer


Graphics by using DDA algorithm;

10. WAP to draw a Line in Computer


Graphics by using BRESENHAM
algorithm;
/*WAP to draw a Star in Computer Graphics;

Programmed by Rohit Kathuria;*/


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

line(200,150,460,150);

line(200,150,330,350);

line(460,150,330,350);

line(200,280,460,280);

line(200,280,330,100); line(460,280,330,100);

outtextxy(300,400,"S T A R");

setcolor(MAGENTA);

outtextxy(200,20,"Programmed by Rohit Kathuria")

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria.

STAR
/* WAP to draw a Computer in Computer Graphics;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

rectangle(200,100,350,200);

//Monitor

line(200,190,350,190);

outtextxy(262,192,"HCL");

circle(335,194,2);circle(325,194,2);

circle(310,194,2);

//monitor buttons

rectangle(225,220,325,240);

rectangle(400,100,460,200);
//CPU

outtextxy(415,112,"DVD");

outtextxy(422,121,"RW");

rectangle(410,110,450,120);

rectangle(410,120,450,130);

rectangle(440,150,455,155);

circle(410,170,2);//Restart

rectangle(408,180,413,185);

//On/off

line(400,100,390,90);

line(400,200,390,190);

line(390,90,390,190);

line(460,100,450,90);

line(390,90,450,90);

line(250,200,250,220);

line(300,200,300,220);

for(i=203;i<=347;i++)

for(j=103;j<=187;j++)
{

putpixel(i,j,GREEN);

}}

rectangle(230,270,320,290);

rectangle(230,280,320,285);

line(230,275,320,275);

rectangle(240,270,250,290);

rectangle(300,270,310,290);

line(260,270,260,290);

line(270,270,280,270);

line(280,270,280,290);

outtextxy(150,50,"Programmed by Rohit Kathuria");

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria.

COMPUTER
/*WAP to draw a Smiley in Computer Graphics;

Programmed by Rohit Kathuria;*/


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

circle(300,200,150);

circle(220,160,20);

circle(280,160,20);

ellipse(280,250,180,330,90,40);

outtextxy(180,30,"Programmed by Rohit Kathuria");

outtextxy(250,380,"S M I L Y");

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria.

SMILEY
/*WAP to draw an Alphabet in Computer Graphics;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

line(150,100,150,180);line(150,100,250,100);

line(150,180,250,180);line(250,180,250,260);

line(150,260,250,260);

//A

line(350,100,300,260);line(350,100,400,260);line(316,210,382
,210);

//D

line(420,100,420,260);

arc(420,180,270,90,80);
settextstyle(8,0,2);

setfillstyle(SOLID_FILL,GREEN);

floodfill(10,10,WHITE);

line(510,100,510,260);

setcolor(MAGENTA);

outtextxy(190,50,"Programmed by Rohit Kathuria");

//Q

circle(200,350,70);line(200,380,280,440);

//E

line(300,290,300,420);line(300,290,380,290);

line(300,355,350,355);line(300,420,380,420);

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria

ALPHABET
/*WAP to draw a Joker in Computer Graphics;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

circle(300,250,120);//face

circle(240,220,20);circle(350,220,20); //eye's

ellipse(300,290,190,350,80,30);

ellipse(300,270,0,360,15,20);

ellipse(240,215,180,360,20,10); circle(350,220,5);

line(300,20,190,200);line(300,20,410,200);circle(300,1
0,8);

outtextxy(270,400,"J O K E R");
setcolor(MAGENTA);

setlinestyle(4,15,1);

outtextxy(50,50,"Programmed by Rohit Kathuria");

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria

JOKER
/*WAP to draw a Flag in Computer Graphics;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

rectangle(150,50,340,140);

line(150,80,340,80);

line(150,110,340,110);

rectangle(150,50,140,350);

rectangle(100,350,200,360);

rectangle(50,360,250,370);

rectangle(5,370,300,380);

circle(240,95,12);

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria

FLAG
/*WAP to draw a Kite in Computer Graphics;

Programmed by Rohit Kathuria; */

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

line(300,100,200,250);

ine(300,100,400,250);

line(200,250,300,350);

line(400,250,300,350);

line(200,250,400,250);

getch();

}
OUTPUT:-

Programmed by Rohit Kathuria

KITE
/*WAP to draw a Hut in Computer Graphics;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,i,j;

initgraph(&gd,&gm," ");

rectangle(150,150,500,350);

line(200,50,150,150);line(200,50,250,150);

line(200,50,500,50);line(500,50,500,150);

//3D

line(200,50,230,20);line(500,50,530,20);line(230,20,530,
20);

line(500,350,530,320);line(530,320,530,20);

//3D

line(250,150,250,350);

line(210,70,500,70); line(220,90,500,90);
line(230,110,500,110); line(240,130,500,130);

line(230,50,280,150); line(260,50,310,150);

line(290,50,340,150); line(320,50,370,150);

line(350,50,400,150); line(380,50,430,150);

line(410,50,460,150); line(440,50,490,150);

line(470,50,500,110); //roof

circle(200,130,19);

rectangle(350,200,450,300);

//door

line(150,150,240,170);

line(150,350,240,330);

line(240,170,240,330);

setfillstyle(BKSLASH_FILL,BLUE);floodfill(12,25,WHITE);

outtextxy(280,420,"H U T");

setcolor(YELLOW);

outtextxy(240,30,"Programmed by Rohit Kathuria");

getch();}
OUTPUT:-

Programmed by Rohit Kathuria

HUT
/*WAP to draw a Line in Computer Graphics by
using DDA algorithms;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,x1=290,y1=100,

x2=100,y2=250,dx,dy,i,l;

float xinc, yinc;

initgraph(&gd,&gm," ");

dx=x2-x1;

dy=y2-y1;

if(dx>=dy)

l=dx;

else

l=dy;

xinc=(dx/l);
yinc=(dy/l);

for(i=l;i<=l;i++);

putpixel(x1,y1,MAGENTA);

x1=x1+xinc;

y1=y1+yinc;

getch();

OUTPUT:-
/*WAP to draw a Line in Computer Graphics by
using BRESHHAM Algorithms;

Programmed by Rohit Kathuria; */


#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

int gd=DETECT,gm,x1=50,y1=120,x2=10,y2=125,dx,dy,i,l;

dx=x2-x1;

dy=y2-y1;

int p=(2*dy)-dx;

initgraph(&gd,&gm," ");

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

if(p<0)

x1=x1+1;

y1=y1+1;
p=p+(2*dy);

else

x1=x1+1;

y1=y1+1;

p=p+(2*dy)-(2*dx);

putpixel(x1,y1,MAGENTA);

getch();

OUTPUT:-

You might also like