cg print outs sem 2 shree ram college bhandup
TRANSCRIPT
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
1/23
PRACTICAL No : 1:
#include
#include
#include
#include
void main()
{
int x1,x2,y1,y2,gd=!"!",gm$
void line%res(int x1 ,int x2, int yl ,int y2)$
clrscr()$
print&('enter the coordinates o& starting points n')$
scan&('*d *d *d *d',+x1,+x2,+y1,+y2)$
initgraph(+gd,+gm,'ctc%gi')$
line%res(x1,x2,y1,y2)$
getch()$
closegraph()$
void line%res(int x1,int x2,int y1,int y2)
{
int dx,dy,x,y$
-oat xend,p$
dx=a%s(x2x1)$
dy=a%s(y2y1)$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
2/23
p=2/dydx$
i&(x1>x2)
{
x=x2$
y=y2$
xend=x1$
else
{
x=x1$
y=y1$
xend=x1$
putpixel(x,y,10)$
hile(x
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
3/23
i&(p
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
4/23
PRACTICAL No : 2:
#include
#include
#include
#include
void main()
{
int xl,x2,yl,y2,gd=!"!",gm$
void draingline(int xl ,int x2, int yl ,int y2)$
print&('enter the coordinates o& starting points n')$
scan&('*d *d *d *d',+xl,+x2,+yl,+y2)$
initgraph(+gd,+gm,'ctc%gi')$
draingline(xl,x2,yl,y2)$
getch()$
closegraph()$
void draingline(int xl ,int x2,int yl ,int y2)
{
int s$
dou%le dy,dx,m,y$
dy=a%s(y2yl)$
dx=a%s(x2xl)$
m=dy4dx$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
5/23
y=yl$
&or(s=xl$s
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
6/23
PRACTICAL No : 3:
#include
#include
#include
#include
plot (int xc,int yc,int x,int y)$
void %circle(int xc,int yc,int r)$
void main()
{
int xc,yc,r$
int gd=!"!",gm$
print&('enter the centre coordinates + radius')$
scan&('*d *d *d',+xc,+yc,+r)$
initgraph(+gd,+gm,'ctc%gi')$
%circle(xc,yc,r)$
putpixel(xc,yc,0)$
getch()$
closegraph()$
void %circle(int xc,int yc,int r)
{
int x,y=r,p=1r$
&or(x=3$x
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
7/23
{
y=(p
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
8/23
PRACTICAL No : 4:
#include
#include
#include
#include#include
void setcolour()$
void main()
{
int xl ,x2,yl ,y2,gd=!"!",gm,c,tx,ty,m,t,x&,y&$
-oat sx,sy$
void line%res(int x1 ,int yl ,int x2,int y2)$
clrscr()$print&('!nter the co ordinates o& starting + ending points')$
scan&('*d *d *d *d'+x1,+x2,+y1,+y2)$
xxxprint&('tt 78!99 1 "8:;9:"; nn')$
prin?('tt 78!99 2 8":"; nn')$
print&('tt 78!99 1 9:;@ nn')$
print&('tt 78!99 1 !A" nn')$
scan&('*d', +c)$
sitch(c)${
case 1
print&('!nter the num%er o& pixel to %e translated')$
scan&('*d *d',+tx,+ty)$
initgraph(+gd,+gm,'')$
setcolor(B)$
line(xl ,x2,yl ,y2)$
getch()$cleardevice()$
setcolor(B)$
lie(xl tx,x2tx,yl ty,y2ty)$
getch()$
closegraph()$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
9/23
%reaC$
case 2
print&('enter the angle o& rotation n')$
scan&('*d',+t)$
print&('i& you ant a simple rotation press 1 n')$print&('else &or Dxed point press 2 n')$
scan&('*d',+m)$
sitch(m)
{
case 1
initgraph(+gd,+gm,'')$
setcolor(B)$
getch()$
cleardevice()$
xl =x1 /cos(t) yl /sin(t)$
yl =xl /smn(t)yl /cos(t)$
setcolor(B)$
line(xl ,x2,yl ,y2)$
getch()$
closegraph()$
%reaC$
case 2
print&('!nter the coordinates o& the Dxed points')$
scan&('*d *d', +x&,+y&)$
initgraph(+gd,+gm,'')$
setcolor(B)$
line(xl ,x2,yl ,y2)$
getch()$cleardevice()$
xl =x&a%s(((xl x&))/cos(t)(yl y&)/sin(t))$
x2=x&a%s(((x2x&))/cos(t)(y2y&)/sin(t))$
yl =y&a%s(((xl x&))/cos(t)(yl y&)/cos(t))$
yl =y&a%s(((x2x&))/sin(t)(y2y&)/cos(t))$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
10/23
setcolor(B)$
line(xl ,x2,yl ,y2)$
getch()$
closegraph()$
%reaC$de&ault
print&('!888EE E')
case 6
print&('!netr the value o& scaling &actor n')$
scan&('*d *&',+sx,+sy)$
print&('i& you ant simple scaling press 1 n')$
print&('else &or Dxed point scaling then press 2n')$
scan&(*d',+m)$
sitch(m)$
{
case 1
initgraph(+gd,+gm,'')$
setcolor(B)$
getch()$
cleardevice()$
setcolor(B)$
line(xl ,x2,yl ,y2)$
getch()$
closegraph()$
%reaC$
case 2
print&('!nter the coordinates o& the Dxed points')$
scan&('*d *d', +x&,+y&)$
initgraph(+gd,+gm,'')$setcolor(B)$
line(xl ,x2,yl,y2)$
getch()$
cleardevice()$
xl =xl /sxx&/(1sx)$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
11/23
x2=x2/sxx&/( 1sx)$
yl =yl /syy&/( 1 sy)$
yl=yl/syy&/(1 sy)$
setcolor(B)$line(xl ,x2,yl ,y2)$
getch()$
closegraph()$
%reaC$
de&ault
print&('!888 EEE)$
getch()$
case 0
exit()$
de&ault
print&('!888 ')$
%reaC$
goto xxx$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
12/23
PRACTICAL No : 5:
#include
#include
#include
#include
#include
void setcolour()$
void main()
{
int gd=!"!",gm,a,%,c,d,e,i,h,F,C,l,s,r,o$
-oat x,y,G,m,n$
char msgHI3J$
print&('!nter Dve num%ers')$
scan&('*d *d *d *d *d',+a,+%,+c,+d,+e)$
clrscr()$
initgraph(+gd,+gm,'ctc%gi')$
i&(a>1233KK%>1233KKc>1233KKd>1233KKe>1233)
{
print&('nnnnntt //// L:M! N!O; "P!
@8:7P////')$
getch()$
closegraph()$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
13/23
x=a42QB3$
h=0I3x$
y=%42.QB3$
i=0I3y$
G=c43.QB3$
F=0I3G$
m=d42.QB3$
C=0I3m$
n=e42.QB3$
l=0I3n$
setcolor(3)$
sprint&(msg,'*d',o)$
outtextxy(R3,062,msg)$
&or(r=1B3,s=l$r
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
14/23
line(3,023,B03,023)$
line(B3,23,B3,0I3)$
&or(r=6I2$r>=03$r=6I)
putpixel(B3, r, 10)$
&or(r=B3$r
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
15/23
PRACTICAL No : 6:
#include
#include
#include
#include
#include
void setcolour()$
void main()
{
int x1,x2,y1,y2,gd=!"!",gm,x,y,m,t,x&,y&$
-oat a,%$
clrscr()$
print&('!nter the co ordinates o& starting + ending points')$
scan&('*d *d *d *d',+x1,+x2,+y1,+y2)$
print&('!nter the angle o& rotation nn')$
scan&('*d',+t)$
a=cos(t/3.31Q0R6)$
%=sin(t/3.31Q0R6)$
print&('i& you ant a simple rotation press 1 n')$
print&('else &or Dxed point rotation press 2 n')$
scan&('*d',+m)$
sitch(m)
{
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
16/23
case 1
initgraph(+gd,+gm,'ctc%gi')$
line(x1,x2,y1,y2)$
getch()$
cleardevice()$
x=x1/ay1/%$
y=x1/%y1/a$
line(x,y,x2,y2)$
getch()$
closegraph()$
%reaC$
case 2
print&('!nter the coordinates o& the Dxed points')$
scan&('*d *d',+x&,+y&)$
initgraph(+gd,+gm,'ctc%gi')$
line(x1,x2,y1,y2)$
getch()$
cleardevice()$
x=x&(x2x&)/a(y2y&)/%$
y=y&(x2x&)/%(y2y&)/a$
line(x1,y1,x,y)$
getch()$
closegraph()$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
17/23
%reaC$
de&ault
print&('!888EEEE')$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
18/23
PRACTICAL No : 7:
#include
#include
#include
#include
#include
void main()
{
int x1,x2,y1,y2,gd=!"!",gm,m,t,x&,y&$
-oat sx,sy$
void line%res(int x1,int y1,int x2,int y2)$
clrscr()$
print&('!nter the co ordinate o& starting + endingpoints')$
scan&('*d *d *d *d',+x1,+x2,+y1,+y2)$
print&('!nter the scaling &actor nn')$
scan&('*& *&',+sx,+sy)$
print&('i& you ant a simple scaling press 1 n')$
print&('else &or Dxed point scaling press 2 n')$
scan&('*d',+m)$
sitch(m)
{
case 1
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
19/23
initgraph(+gd,+gm,'ctc%gi')$
line(x1,x2,y1,y2)$
getch()$
cleardevice()$
line%res(x1/sx,y1/sy,x2/sx,y2/sy)$
getch()$
closegraph()$
%reaC$
case 2
print&('!nter the coordinates o& the Dxed points')$
scan&('*d *d', +x&,+y&)$
initgraph(+gd,+gm,'ctc%gi')$
line%res(x1,x2,y1,y2)$
getch()$
cleardevice()$
x1 =x1/sxx&/(1sx)$
y1 =y1/syy&/(1sy)$
x2 =x2/sxx&/(1sx)$
y2 =y2/sxy&/(1sy)$
line%res(x1,y1,x2,y2)$
getch()$
closegraph()$
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
20/23
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
21/23
xend=x2$
putpixel(x,y,10)$
hile(x
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
22/23
PRACTICAL No : 8:
#include
#include
#include
#include
#include
void %circle(int xc,int yc,int r)$
void main()
{
int gd=!"!", gm, c,xc, yc$
-oat tx,ty,r$
print&('!nter the co ordinate + radius')$
scan&('*d *d *d ',+xc,+yc,+r)$
print&('!nter the num%er o& pixel to %e translated nn')$
scan&('*& *&',+tx,+ty)$
initgraph(+gd, +gm ,'ctc%gi')$
%circle(xc,yc,r)$
putpixel(xc,yc,0)$
getch()$
closegraph()$
void %circle(int xc,int yc,int r)
{
-
8/15/2019 CG Print Outs Sem 2 Shree Ram College Bhandup
23/23
int x,y=r,p=1r$
&or(x=3$x