8/15/2019 21919086 Graphics File
1/133
CONTENTS
Program Page No.
1. Generating Line Primitive
1.a Digital Differential Analyzer (DDA) 3
1.b Mid Point Approac ! 1.c "re#enam$# Approac 1%
&. Generating 'ircle
&.a Mid Point Approac (1#t order) 1
&.b Mid Point Approac (&nd order) 1
&.c "re#enam$# Approac &%
3. Generating *llip#e
3.a Mid Point Approac (1#t order) &3
3.b Mid Point Approac (&nd order) &!
3.c "re#enam$# Approac &+
. Generating ,yperbola
.a Mid Point Approac (1#t order) 3&
.b "re#enam$# Approac 3-
-. Generating Parabola
-.a Mid Point Approac (1#t order) 3
-.b Mid Point Approac (&nd
order) 1 -.c "re#enam$# Approac
!. Program to perform 'oen /0terland Line 'liiping
. Program to perform Liang "ar#ey Line 'lipping -1
. Program to perform 'yr0# "ec 'lipping --
+. Program to perform MidPoint /0bdivi#ion Line 'lipping -
1%. Program to perform Nicoll Lee Nicoll Line 'lipping !&
11. Program to perform /0terland ,odgemann Polygon 'lipping %
1&. Program to perform 2eiler Aterton Polygon 'lipping !
8/15/2019 21919086 Graphics File
2/133
13. Program to ill Polygon 0#ing /eed ill 1
1. Program to ill Polygon 0#ing /canline Metod
1-. Program to perform &D 4ran#formation# +
1!. Program to perform 3D 4ran#formation# 1%
1. Program for anti5alia#ing 0#ing G0pta /pro0ll$# Approac 1%+
1. ,idden /0rface *limination 6 7 "0ffer approac 11&
1+. ,idden /0rface *limination 6 "ac ace Detection 1&%
&%. 3D 8ie9ing 1&!
&1. Program to generate a "ezier '0rve 13%
&&. Program to generate a ,ermite '0rve 3&
&3. Program to generate a "5/pline c0rve 13-
8/15/2019 21919086 Graphics File
3/133
L:N* D;A2:NG 6 DDA
#include#include
#include
#include
void put_pixel(int x, int y, int col)
{
putpixel(x+3!, "!y, col)$%
int round(&loat x)
{ dou'le rem &mod((dou'le)x,.!)$
i&(x
return (&loor((dou'le)x))$
else return (ceil((dou'le)x))$
%
void dda(int x, int y, int x, int y)
{
int xa,ya,x',y'$
setcolor(-)$ line(3!,!,3!,"!)$
setcolor(/01)$
line(!,"!,2"!,"!)$
setcolor(456)$
i&(x
8/15/2019 21919086 Graphics File
4/133
put_pixel(round(x),round(y),*)$
%
%
void main()
{
clrscr()$ int x,y,x,y$
coutx>>y$
coutx>>y$
int gd -66, gm$
initgraph(=gd,=gm,:c;tc'gi:)$ dda(x,y,x,y)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
5/133
8/15/2019 21919086 Graphics File
6/133
L:N* D;A2:NG 5 M:D P
8/15/2019 21919086 Graphics File
7/133
%
put_pixel(x,y,*)$
% %
else i&(m> == m
{
put_pixel(xa,ya,*)$ d .!7dy+dx$
9hile(x!)
{
88case n
d dx$y++$
% else
{d+ dydx$
x++$ y++$
% put_pixel(x,y,*)$
%
%
else i&(m
8/15/2019 21919086 Graphics File
8/133
d+ dx$
y$
% put_pixel(x,y,*)$
%
%
%
void main()
{
clrscr()$ int x,y,x,y$
coutx>>y$
coutx>>y$
int gd -66, gm$
initgraph(=gd,=gm,:c;tc'gi:)$
mid_pt(x,y,x,y)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
9/133
8/15/2019 21919086 Graphics File
10/133
L:N* D;A2:NG 6 ";*/*N,AM$/ APP;! == m
8/15/2019 21919086 Graphics File
11/133
%
put_pixel(x,y,*)$
% %
else i&(m>)
{
d7dxdy$ 9hile(x
i&(d
{
d7dy$x++$
%
else
{d7(dx+dy)$
y$x++$
% put_pixel(x,y,*)$
%
% else i&(m
8/15/2019 21919086 Graphics File
12/133
%
%
%
void main()
{ clrscr()$
int x,y,x,y$
coutx>>y$ coutx>>y$
int gdriver -66, gmode$ initgraph(=gdriver, =gmode, :c;tc'gi:)$
'rsnhm_line(x,y,x,y)$
getch()$ closegraph()$
%
8/15/2019 21919086 Graphics File
13/133
8/15/2019 21919086 Graphics File
14/133
':;'L* 5 M:D P
%
else {
d+*+7(xy)$
x++$
y$ %
plotpixel(x,y,xc,yc)$
%
%
void main()
{
clrscr()$
int xc,yc$
coutxc>>yc$
8/15/2019 21919086 Graphics File
15/133
int r$ 88radius
coutr$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
circ(r,xc,yc)$
getch()$
closegraph()$%
8/15/2019 21919086 Graphics File
16/133
1%%
8/15/2019 21919086 Graphics File
17/133
':;'L* 6 M:D P
de+$
dse+$ x++$
%
else
{ d+dse$
de+$
dse+"$
x++$ y$
%
plotpixel(x,y,xc,yc)$
%%
void main()
{ clrscr()$
8/15/2019 21919086 Graphics File
18/133
int xc,yc$
coutxc>>yc$
int r$ 88radius
coutr$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
circ(r,xc,yc)$
getch()$
closegraph()$%
8/15/2019 21919086 Graphics File
19/133
8/15/2019 21919086 Graphics File
20/133
':;'L* 6 ";*/*N,AM$/ APP;
8/15/2019 21919086 Graphics File
21/133
int r$ 88radius
coutr$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
circ(r,xc,yc)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
22/133
8/15/2019 21919086 Graphics File
23/133
*LL:P/* 6 M:D P
8/15/2019 21919086 Graphics File
24/133
else
{
d+ a7a7(37y)7.!$ y$
%
plotpixel(x,y)$
%
%
void main(){
clrscr()$
&loat a,'$ cout
8/15/2019 21919086 Graphics File
25/133
8/15/2019 21919086 Graphics File
26/133
*LL:P/* 5 M:D P
dse+7'7'$
x++$ %
else
{
d+ dse$ de+7'7'$
dse+7(a7a+'7')$
x++$
y$ %
plotpixel(x,y)$
%
d '7'7(.!7x+!.*)7(.!7x+!.*)+.!7a7a7(y)7(y).!7a7a7'7'$
&loat ds a7a7(37y)$
dse 7'7'7(+x) + a7a7(37y)$
9hile(y>!)
8/15/2019 21919086 Graphics File
27/133
{
i&(d
{ d+ dse$
ds+7a7a$
dse+7(a7a+'7')$
x++$ y$
%
else
{ d+ ds$
ds+7a7a$
dse+7a7a$
y$ %
plotpixel(x,y)$
%
%
void main()
{
clrscr()$
&loat a,'$
cout
8/15/2019 21919086 Graphics File
28/133
8/15/2019 21919086 Graphics File
29/133
*LL:P/* 6 ";*/*N,AM$/ APP;!) {
i&(d > ('7'7!.*))
{
d+ 27a7a "7a7a7y$ y$
%
else
{ d+ ('7'7"7(+x)) + 7a7a ("7a7a7(y))$
x++$
y$
% plotpixel(x,y)$
8/15/2019 21919086 Graphics File
30/133
%
%
void main()
{
clrscr()$ dou'le a,'$
cout
8/15/2019 21919086 Graphics File
31/133
8/15/2019 21919086 Graphics File
32/133
,?P*;"
8/15/2019 21919086 Graphics File
33/133
else
{
dd+7y+7p$ y++$
%
putpixel(x+3!+xc,"!yyc,-)$
delay(!)$ putpixel(x+3!+xc,"!+yyc,-)$
delay(!)$
%
getch()$%
8/15/2019 21919086 Graphics File
34/133
8/15/2019 21919086 Graphics File
35/133
,?P*;"
8/15/2019 21919086 Graphics File
36/133
%
plotpixel(x,y)$
%
%
void main(){
clrscr()$
dou'le a,'$
cout
8/15/2019 21919086 Graphics File
37/133
8/15/2019 21919086 Graphics File
38/133
PA;A"
8/15/2019 21919086 Graphics File
39/133
%
void main(){
clrscr()$
dou'le a$
couta$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$ para(!,!,a)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
40/133
8/15/2019 21919086 Graphics File
41/133
PA;A"
dou'le de "7a$ dne "7a 7(+y)$
9hile( y < ! )
{
i&(d
d+ de$
x++$
% else
8/15/2019 21919086 Graphics File
42/133
{
d+ dne$
dne+$ x++$
y++$
%
put_pixel(x,y)$ %
%
void main()
{
clrscr()$
dou'le a$ couta$
int gdriver -66, gmode$ initgraph(=gdriver, =gmode, :c;tc'gi:)$
para(!,!,a)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
43/133
8/15/2019 21919086 Graphics File
44/133
PA;A"!) {
d+ ("7a)$
x++$
% else
{
d+ + 7y "7a$
x++$ y++$
8/15/2019 21919086 Graphics File
45/133
%
plotpixel(x,y)$
%
%
void main(){
clrscr()$
dou'le a$
couta$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$ para(!,!,a)$
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
46/133
8/15/2019 21919086 Graphics File
47/133
L:N* 'L:PP:NG 5 '
8/15/2019 21919086 Graphics File
48/133
done $
outtextxy(!,3!!,:n Lorry? 0ine reMected:)$
% else
{
i&((x> x9min == x y9max == y>x9max$
couty9min>>y9max$
8/15/2019 21919086 Graphics File
49/133
coutx>>y$ coutx>>y$
lin(x+3!!,"!y,x+3!!,"!y,x9min+3!!,"!y9min,x9max+3!!,"!y9max)$ 88 i have interchanged y9min and y9max here 'eacuse 9e are doing "!y
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
50/133
8/15/2019 21919086 Graphics File
51/133
L:N* 'L:PP:NG 5 L:ANG "A;/@*?
#include
#include
#include
#include
&loat max(&loat a,&loat ',&loat c,&loat d)
{ &loat e,&$ i&(a>')
{
ea$
% else
{
e'$
% i&(c>d)
{
&c$
%
else {
&d$ %
i&(e>&)
{
return e$ %
else
{
return &$ %
%
&loat min(&loat g,&loat h,&loat m,&loat M){
&loat N,l$
i&(g
8/15/2019 21919086 Graphics File
52/133
%
else
{ return l$
%
%
void main()
{
int gd-66$
int gm$ initgraph(=gd,=gm,:c;tc'gi:)$
&loat x,x,y,y,uO"P{!%,pO!P,i$
&loat QO!P,dx,dy,xmin,xmax,ymin,ymax$
&loat xm,ym,xn,yn$ coutx>>y>>x>>y>>xmin>>xmax>>ymin>>ymax$
setcolor(/01)$
line(3!+xmin,"!ymin,3!+xmax,"!ymin)$ line(3!+xmin,"!ymin,3!+xmin,"!ymax)$
line(3!+xmax,"!ymax,3!+xmax,"!ymin)$
line(3!+xmin,"!ymax,3!+xmax,"!ymax)$
setcolor(EF)$
line(3!+x,"!y,3!+x,"!y)$ getch()$
dxxx$
dyyy$ pOPdx$pOPdx$pO3Pdy$pO"Pdy$
QOPxxmin$
QOPxmaxx$
QO3Pyymin$ QO"Pymaxy$
&loat u!.!$
&loat u.!$
&or(i$i
i&(u
{ u!$
%
uOP$uOP$uO3P$uO"P$
&or(i$i)
{
u$ %
i&(pOP!)
{
i&(QOP
8/15/2019 21919086 Graphics File
53/133
exit(!)$
%
% i&(u>u)
{
exit(!)$
% xmx+u7dx$
ymy+u7dy$
xnx+u7dx$
yny+u7dy$ setcolor(456)$
line(3!+xm,"!ym,3!+xn,"!yn)$
getch()$
%
8/15/2019 21919086 Graphics File
54/133
8/15/2019 21919086 Graphics File
55/133
L:N* 'L:PP:NG 5 '?;=/ "*'@
#include
#include
#include
struct point
{
&loat x,y$%$
void clip(point polO!P, point p, point p, int n)
{
cleardevice()$
setcolor(/01)$
line(3!,!,3!,"!)$
setcolor(-)$ line(!,"!,2"!,"!)$
setcolor(K00H)$
&or(int i!$it_enter)
t_enter t$
% else i&(den>!)
{
i&(t
8/15/2019 21919086 Graphics File
56/133
pi.xp.x+(p.xp.x)7t_enter$
pi.yp.y+(p.yp.y)7t_enter$
pl.xp.x+(p.xp.x)7t_leave$ pl.yp.y+(p.yp.y)7t_leave$
setcolor(EF)$
line(pi.x,pi.y,pl.x,pl.y)$
%
void main()
{
int gd -66, gm$ initgraph(=gd,=gm,:c;tc'gi:)$
coutn$
point polO!P$
cout
8/15/2019 21919086 Graphics File
57/133
8/15/2019 21919086 Graphics File
58/133
M:D P9max.y)
code codeJ/H66HC$
i&(p.y
8/15/2019 21919086 Graphics File
59/133
&loat ds dsx>dsyRdsx;dsy$
return ds$
%
void midpt(point 9min, point 9max, point p, point p)
{
setcolor(-)$ point t$
i& (p.x > p.x)
{
t p$ p p$
p t$
%
char code getcode(p,9min,9max)$
char code getcode(p,9min,9max)$
i&((code = code)?!) {
return$
%
else i&(((code = code)!) == ((code J code)!))
{ line(p.x, p.y, p.x, p.y)$
%
else {
t mid(p,p)$
i&((dist(t,p,9min,9max) > ) JJ (dist(t,p,9min,9max) > ))
{ char codm getcode(t, 9min, 9max)$
i&(isin(t,9min,9max))
{ i&(isin(p,9min,9max))
{ line(p.x,p.y,t.x,t.y)$
pt$ midpt(9min,9max,p,p)$
%
else i&(isin(p,9min,9max)) {
line(p.x,p.y,t.x,t.y)$
pt$
midpt(9min,9max,p,p)$ %
else
{ midpt(9min,9max,p,t)$
midpt(9min,9max,t,p)$
%
% else
{
i& ((code=codm)?!)
{ pt$
8/15/2019 21919086 Graphics File
60/133
%
else i&((code=codm)?!)
{ pt$
%
midpt(9min,9max,p,p)$
% %
%
%
void main()
{
clrscr()$
point 9min,9max,p,p$ cout9min.x$
cout9min.y$ cout9max.x$
cout9max.y$
cout>p.x$
cout>p.y$
cout>p.x$
cout>p.y$
int gdriver -66, gmode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$ setcolor(EF)$
rectangle(9min.x,9min.y,9max.x,9max.y)$ setcolor(KDF)$
line(p.x,p.y,p.x,p.y)$ getch()$
midpt(9min,9max,p,p)$
getch()$ closegraph()$
%
8/15/2019 21919086 Graphics File
61/133
8/15/2019 21919086 Graphics File
62/133
L:N* 'L:PP:NG 5 N:',xmin$
cout>ymin$
cout>xmax$
cout>ymax$
cout>x$
cout>y$
cout>x$ cout>y$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
setcolor()$
agetmaxx()8$ 'getmaxy()8$
line(!,',7a,')$
line(a,!,a,7')$
rectangle(a+xmin,'ymin,a+xmax,'ymax)$ setcolor(!)$
line(a+x,'y,a+xmin,'ymin)$
line(a+x,'y,a+xmax,'ymin)$
line(a+x,'y,a+xmax,'ymax)$ line(a+x,'y,a+xmin,'ymax)$
getch()$
setcolor()$
line(!,',7a,')$ line(a,!,a,7')$
setcolor(3)$
line(a+x,'y,a+x,'y)$
getch()$ ch&irst_end_point_region(x,y)$
8/15/2019 21919086 Graphics File
63/133
s9itch(ch)
{
case ; clipline(x,y,x,y)$ 'reaN$
case ; clipline(x,y,x,y)$
'reaN$
case 3 ; clipline3(x,y,x,y)$ 'reaN$
de&ault; coutm == xx)) == y>y)
{ coutm == mx)
8/15/2019 21919086 Graphics File
64/133
{ 88 point p is inside clip 9indo9
i&(xm3 == x>x) JJ (a's(m)>a's(m") == x
8/15/2019 21919086 Graphics File
65/133
void clipline(int x,int y,int x,int y)
{ int dra9$
&loat m,m,m,m3,m"$ int nx,ny,nx,ny$
m((&loat)(yy))8(xx)$
m((&loat)(yminy))8(xminx)$
m((&loat)(yminy))8(xmaxx)$ m3((&loat)(ymaxy))8(xmaxx)$
m"((&loat)(ymaxy))8(xminx)$
88 Ioint p is in 0e&t'ottom region
i&(m>m == mxmin) { 88 Ioint p is inside the clip 9indo9
i&(y>ymin)
{
nxxmin$ nyy+m7(xminx)$
nxx$
nyy$
% 88 Ioint p is outside the clip 9indo9
else
{
nxxmin$
nyy+m7(xminx)$ nyymin$
nxx+(yminy)8m$
% %
88 Ioint p is in 0e&tight region
else i&(m>m == mxmin)
{ 88 Ioint p is inside the clip 9indo9 i&(xm3 == m
8/15/2019 21919086 Graphics File
66/133
{
nxxmin$
nyy+m7(xminx)$ nyymax$
nxx+(ymaxy)8m$
%
% else
dra9!$
setcolor()$
rectangle(a+xmin,'ymin,a+xmax,'ymax)$ i&(dra9)
{
setcolor(!)$
line(a+x,'y,a+xmin,'ymin)$ line(a+x,'y,a+xmax,'ymin)$
line(a+x,'y,a+xmax,'ymax)$
line(a+x,'y,a+xmin,'ymax)$
setcolor(*)$ line(a+nx,'ny,a+nx,'ny)$
%
%
87 Ioint p is in the orner egion 78void clipline3(int x,int y,int x,int y)
{
int dra9$ &loat m,m,m,m3,m",tm,tm$
int nx,ny,nx,ny$
int &lag,t$
tm((&loat)(yminy))8(xminx)$ tm((&loat)(ymaxymin))8(xmaxxmin)$ 88diagonal slope
m((&loat)(yy))8(xx)$
m((&loat)(yminy))8(xmaxx)$
m((&loat)(ymaxy))8(xmaxx)$ m3((&loat)(yminy))8(xminx)$
m"((&loat)(ymaxy))8(xminx)$ 88 Ioint p is to9ards the le&t side o& the clip 9indo9 (case)
i&(tm
8/15/2019 21919086 Graphics File
67/133
%
88 Ioint p is inside the clip 9indo9
else i&(y>ymin == xm == mymax)
{nyymin$
nxx+(yminy)8m$
nxx+(ymaxy)8m$
nyymax$
% 88 Ioint p is inside the clip 9indo9
else i&(y>ymin)
{ nyymin$
nxx+(yminy)8m$
nxx$
nyy$ %
%
88 Ioint p is in 0e&tight region (case)
else {
88 Ioint p is outside the clip 9indo9 i&(x>xmax)
{nxxmin$
nyy+m7(xminx)$
nxxmax$nyy+m7(xmaxx)$
%
88 Ioint p is inside the clip 9indo9
else i&(x>xmin) {
nxxmin$
nyy+m7(xminx)$
nxx$ nyy$
%
%
% 88 Ioint p is in 0e&ttop region
else i&(m>m3 == m
8/15/2019 21919086 Graphics File
68/133
{
nxxmin$
nyy+m7(xminx)$ nxx+(ymaxy)8m$
nyymax$
%
88 Ioint p is inside the clip 9indo9 else i&(y>ymin)
{
nxxmin$
nyy+m7(xminx)$ nyy$
nxx$
%
% else
dra9!$
getch()$
setcolor()$ rectangle(a+xmin,'ymin,a+xmax,'ymax)$
i&(dra9)
{
setcolor(!)$
line(a+x,'y,a+xmin,'ymin)$ line(a+x,'y,a+xmax,'ymin)$
line(a+x,'y,a+xmax,'ymax)$
line(a+x,'y,a+xmin,'ymax)$ setcolor(*)$
line(a+nx,'ny,a+nx,'ny)$
%
%
8/15/2019 21919086 Graphics File
69/133
8/15/2019 21919086 Graphics File
70/133
P
8/15/2019 21919086 Graphics File
71/133
tONP.y ay$
N++$
tONP sOM+P$N++$
%
88i > o
else i&(sOMP.xclOP.x) {
int ay int(((clOP.xsOMP.x)7(sOM+P.ysOMP.y)8(sOM+P.xsOMP.x)7.!)+sOMP.y)$
tONP.x clOP.x$
tONP.y ay$N++$
%
88i > i
else i&(sOMP.x do nothing
%
%
else i&(i) 88 /H66HC -E
{ &or(int M!$M i i&(sOMP.y>clOP.y == sOM+P.y o
else i&(sOMP.yclOP.y) {
int ax int(((clOP.ysOMP.y)7(sOM+P.xsOMP.x)8(sOM+P.ysOMP.y)7.!)+sOMP.x)$
tONP.x ax$tONP.y clOP.y$
N++$
%
88i > i else i&(sOMP.y do nothing
%
% else i&(i3) 88 0G6 -E
{
&or(int M!$M i
8/15/2019 21919086 Graphics File
72/133
i&(sOMP.xclO!P.x)
{
88&ind point o& intersectionint ay int(((clO!P.xsOMP.x)7(sOM+P.ysOMP.y)8(sOM+P.xsOMP.x)7.!)+sOMP.y)$
tONP.x clO!P.x$
tONP.y ay$
N++$tONP sOM+P$
N++$
%
88i > o else i&(sOMP.x>clO!P.x == sOM+P.x i else i&(sOMP.x>clO!P.x == sOM+P.x>clO!P.x)
{
tONP sOM+P$
N++$
% 88o > o > do nothing
%
% tONPtO!P$
&or(int l!$l
8/15/2019 21919086 Graphics File
73/133
i&((p.x > clO!P.x)==(p.x clO!P.y)==(p.y
8/15/2019 21919086 Graphics File
74/133
cout
8/15/2019 21919086 Graphics File
75/133
8/15/2019 21919086 Graphics File
76/133
P#include
&loat sdxO*P,sdyO*P$int i,9!,h$void sort(&loat sdyOP,int h)
{
&loat temp$
&or(int M!$M
8/15/2019 21919086 Graphics File
77/133
8/15/2019 21919086 Graphics File
78/133
TOiP.youtyOiP$
TOiP.vis!$
% s!$
&or(m!$m
8/15/2019 21919086 Graphics File
79/133
%
%
getch()$%
8/15/2019 21919086 Graphics File
80/133
8/15/2019 21919086 Graphics File
81/133
/**D :LL
#include
#include
#include
int main(void)
{
int gdriver -66, gmode, errorcode$ int i,n,c,'oun$ &loat xO!P,yO!P,a,',l,m$
int poly&ill(&loat,&loat,int,int)$
int ply&ill(&loat,&loat,int,int)$
int ply&ll(&loat,&loat,int,int)$ int ply&il(&loat,&loat,int,int)$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
coutn$ &or(i!$i>yOiP$
% coutc$ cout>'$ xOiPxO!P,yOiPyO!P$
setcolor('oun)$
&or(i!$i
8/15/2019 21919086 Graphics File
82/133
rgetpixel(3!+p,"!(Q))$
i&((r?'o)==(r?c))
{ putpixel(3!+p,"!Q,c)$
ply&ill(p,(Q+),c,'o)$
ply&ill(p+,Q,c,'o)$
%%
int ply&il(&loat p,&loat Q,int c,int 'o)
{ int r$
rgetpixel(3!+p,"!(Q))$
i&((r?'o)==(r?c))
{ putpixel(3!+p,"!Q,c)$
ply&il(p,(Q+),c,'o)$
ply&il(p,Q,c,'o)$
%%
int ply&ll(&loat p,&loat Q,int c,int 'o)
{
int r$ rgetpixel(3!+p,"!(Q))$
i&((r?'o)==(r?c))
{ putpixel(3!+p,"!Q,c)$
ply&ll(p,(Q),c,'o)$
ply&ll(p,Q,c,'o)$
%%
8/15/2019 21919086 Graphics File
83/133
8/15/2019 21919086 Graphics File
84/133
P
8/15/2019 21919086 Graphics File
85/133
78
class linNed_list_E6
{ protected;
node7 head$
pu'lic;
linNed_list_E6(){ headF100$ %
87 i am passing a node to insert &unctions as
to insert in D6 i 9ill remove nodes &rom E6 and put in D6. as they 9ont 'e reQuired 'y E6 anymore.
&or insertion in E6 prepare the node 'y calling getnode
&unction and then call insert.
this 9ay i can insert lists at the end and in the 'eginning.78 void insert_at_head(node7 n)$
void insert_at_end(node7 n)$
int sort()$
87 &or merging a list in the D6 address in the head pointer
is reQuired.this &unction returns that address
78 node7 access_head()
{ return head$ %
87 searches the item in the list. in the end child
points to the element searching &or and parent points to the previous element.
here the tasN is 'ascially 9hether an edge has 'een
included in E6 or not
78 int search(node7 item,node7 =parent,node7 =child)$
void display()$
%$
87 D6 tasNs reQuired;. insertion;have to insert a 9hole list &rom E6, hence doing insertion
at end.(derived &rom the 'ase class). sorting;the list has to 'e sorted according to increasing x values
(derived &rom the 'ase class)3. update;as y is increased ne9 intersection points have to 'e calculated
". delete;have to delete those edges 9hich are complete
*. dra9ing;list has to 'e dra9n in pairs2. display;reQuired &or testing purposes (derived &rom the 'ase class)
78
class linNed_list_D6;pu'lic linNed_list_E6
{ pu'lic;
linNed_list_D6();linNed_list_E6()
{
%
87 &or a ne9 scanline the ne9 intersection points have
to 'e calculated. this is done 'y xx+delx (coherence
property). update &unction per&orms this tasN 78 void update()$
87 this &unction checNs 9hether the &irst or the last
element has to 'e deleted or not return values;
8/15/2019 21919086 Graphics File
86/133
!;no
;yes
78 int del_&irst_or_last(int y)$
87 searches the item in the list. in the end child
points to the element searching &or and parent
points to the previous element. return values;
not &ound;!
&ound;
78 int search(int y,node7 =parent,node7 =child)$
87 return values;
no deletion;!
deletion;78 int delete_&irst()$
87 have to use this only 9hen in D6 ymax o& an edge
is reached. hence search &or y and delete i& &ound also i 9ant to Nno9 i& anyone o& the &irst or the last
node is 'eing deleted.
return values;
no deletion;!
deletion;78 int delete_item(int y)$
87 to &ill the polygon 9e have to dra9 in pairs &rom the x values o& the node at the y value passed as an argument.
78 void dra9(int y)$
%$
87 array &or the lists o& E6. as no o& edges cant exceed no
o& vertices,no o& lists are even lesser so this is a sa&e upper limit
the array yindex stores the y value at 9hich the list at the corresponding
index in 'oth arrays 9ould 'e in the actual algo.78 linNed_list_E6 E6OCDSP$
int yindexOCDSP{!%$
87 &or non horiTontal edges gets a node and inserts it in appropriate list paramenters;
a; the current vertex
'; the adMoining vertex78 void maNe_insert_edge(point a,point ',int ycur)$
87 taNe each edge one 'y one starting &rom ymin and put it in the
corredponding position in E6 and the y value in yindex paramenters; p ,p, n (polygon data)
a&ter this &unction call E6 is completely ready
78 void maNe_E6(point pOCDSP,point pOCDSP,int n)$
void goto_graphics_mode()$
void dra9_poly(point pOCDSP,int n)$
87 start 9ith empty list and move &rom ymin to ymax. &or every y do
update
merge
sort delete
8/15/2019 21919086 Graphics File
87/133
dra9
i& delete &rom st or last then &irst dra9 and delete,
then do the normal dra9 parameters;
p,n;reQuired to get ymin and ymax
78 void process_D6(point pOCDSP,int n)$
void scanline(point pOCDSP,point pOCDSP,int n)
{
87 polygon o'tained. no9 sort them according to increasing y values
and store them in another array78 copy(p,p,n)$
sort(p,n)$
87 polygon in 'oth arrays. maNe E6(glo'al edge ta'le). this completes the E6 9ith all the lists sorted also
78 maNe_E6(p,p,n)$
goto_graphics_mode()$dra9_poly(p,n)$
87 no9 Must process D6. this &ills the polygon
78 process_D6(p,n)$
%void main()
{
87p is the polygon 9ith the vertices in the cyclic order
n has the no o& vertices in the polygon
78
point pOCDSP,pOCDSP$int n$
87the vertices o& the polygon should 'e stored in the text &ile
polygon.txt 'ut &or testing and simpli&ying purposes using
'rute &orce, so &irst retrieve them and store in p78 getdata(p,n)$
scanline(p,p,n)$
getch()$
%
void getdata(point pOCDSP,int =n)
{
nA$
pO!P.x$ pO!P.y*$
pOP.x$ pOP.y@$
pOP.x"$ pOP.y@$
pO3P.x"$ pO3P.yA$
pO"P.x2$ pO"P.yA$
pO*P.x2$ pO*P.y@$
pO2P.x$ pO2P.y@$ [email protected]$ [email protected]$
pOP.x!$ pOP.yA$
pOAP.x!$ pOAP.y@$ pO!P.x"$ pO!P.y@$
8/15/2019 21919086 Graphics File
88/133
pOP.x$ pOP.y$
pOP.x!$ pOP.y$ pO3P.x!$ pO3P.y3$
pO"P.x$ pO"P.y3$
pO*P.x$ pO*P.y$
pO2P.x2$ pO2P.y$
[email protected]$ [email protected]$
pOP.x"$ pOP.y3$
&or(int i!$i
8/15/2019 21919086 Graphics File
89/133
temptemp>linN$
temp>linNhead$
headn$%
void linNed_list_E6;;insert_at_end(node7 n)
{
i&(headF100)insert_at_head(n)$
else
{
node7 temphead$88go to the end
9hile(temp>linN?F100)
temptemp>linN$
87 place the ne9 data at the end more than one node can 'e inserted at a time.
to 'e speci&ic a list can 'e concatenated at the end
78
temp>linNn$%
%
int linNed_list_E6;;sort()
{
i&(headF100)return !$
else
{node7 temphead$
node7 temphead$
node7 temp_posF100$
int temp_ymax$&loat temp$
9hile(temp>linN?F100)
temptemp>linN$
88temp is at the last node9hile(temp?head)
{temphead$
9hile(temp?temp){
i&( temp>x > temp>linN>x )
{88s9apping values
temp_ymaxtemp>ymax$
temp>ymaxtemp>linN>ymax$
temp>linN>ymaxtemp_ymax$
temptemp>x$
temp>xtemp>linN>x$
temp>linN>xtemp$
temptemp>delx$
temp>delxtemp>linN>delx$
temp>linN>delxtemp$%
temp_postemp$
temptemp>linN$
%temptemp_pos$
8/15/2019 21919086 Graphics File
90/133
%
return $
%%
int linNed_list_E6;;search(node7 item,node7 =parent,node7 =child)
{
88parent &ollo9s the childchildhead$
9hile(child?F100)
{
i&(child>ymaxitem>ymax == child>xitem>x == child>delxitem>delx)return $
parentchild$
childchild>linN$
%return !$
%
void linNed_list_E6;;display()
{i&(headF100)
cout
8/15/2019 21919086 Graphics File
91/133
{
88parent &ollo9s the child
childhead$9hile(child?F100)
{
i&(child>ymaxy)
return $ parentchild$
childchild>linN$
%
return !$%
int linNed_list_D6;;delete_&irst()
{
i&(headF100)return !$
node7 nhead$
headhead>linN$
&ree(n)$return $
%
int linNed_list_D6;;delete_item(int y)
{
node7 parent$node7 child$
i&( search(y,parent,child) )
{i&(childhead)
return delete_&irst()$
else
{ parent>linNchild>linN$
&ree(child)$
return $
%%
elsereturn !$
%void linNed_list_D6;;dra9(int y)
{
node7 temphead$int &irst,next$
9hile(temp?F100)
{
88move &or9ard 'y to dra9 in pairs&irsttemp>x$
temptemp>linN$
i&(tempF100)
'reaN$nexttemp>x$
temptemp>linN$
line(xorigin+&irst,yoriginy,xorigin+next,yoriginy)$
%
%
void maNe_insert_edge(point a,point ',int ycur){
8/15/2019 21919086 Graphics File
92/133
i&(a.y?'.y)88&or non horiTontal edges
{
int ymax,x$88select ymax and x(ymin)
i&(a.y>'.y)
{
ymaxa.y$x'.x$
%
else
{ymax'.y$
xa.x$
%
&loat delx(a.x'.x)7.!8(a.y'.y)$node 7tempgetnode(ymax,x,delx)$
88checN i& this edge has already 'een included in E6 or not
int &ound!$&or(int i!$i
8/15/2019 21919086 Graphics File
93/133
&or(int M!$M
8/15/2019 21919086 Graphics File
94/133
%
D6.sort()$
87 deletion
i& st or last element is to 'e deleted,
then &irst dra9 and then delete and do this &or all the nodes that are to 'e deleted
78
int &lag!$
87 &ind i& there is deletion &rom st or last node i& yes then dra9 and del all else Must del all
78
&lagD6.del_&irst_or_last(i)$
i&(&lag){
setcolor(LI5D0)$
D6.dra9(i)$
88D6.display()$getch()$
%
&lag$
9hile(&lag){
&lagD6.delete_item(i)$
%87 D6.display()$
cout
8/15/2019 21919086 Graphics File
95/133
8/15/2019 21919086 Graphics File
96/133
&D 4;AN/
8/15/2019 21919086 Graphics File
97/133
void rot_gen()
{
char Ney$ int sQO"POP$
initia(sQ)$
&loat d!$
9hile((Neygetch())?VeV) {
i&(((int)Ney)@*)
{
d+!.!$ cleardevice()$
rot(sQ,sQ,!,!,d)$
%
else i&(((int)Ney)@@) {
d!.!$
cleardevice()$
rot(sQ,sQ,!,!,d)$ %
%
&or(int i!$i>ry$ 9hile((Neygetch())?VeV)
{
i&(((int)Ney)@*) {
d+!.!$
cleardevice()$
rot(sQ,sQ,rx,ry,d)$ %
else i&(((int)Ney)@@)
{
d!.!$ cleardevice()$
rot(sQ,sQ,rx,ry,d)$
%
% &or(int i!$i
8/15/2019 21919086 Graphics File
98/133
closegraph()$
%
void translation()
{
initia(sQ)$
int xincr, yincr$ char Ney$
9hile((Neygetch())?VeV)
{
i&(((int)Ney)@) {
yincr *$
xincr !$
cleardevice()$ incr(sQ,xincr,yincr)$
put_'ox(sQ)$
%
else i&(((int)Ney)!) {
yincr*$
xincr!$
cleardevice()$
incr(sQ,xincr,yincr)$ put_'ox(sQ)$
%
else i&(((int)Ney)@*) {
yincr!$
xincr*$
cleardevice()$ incr(sQ,xincr,yincr)$
put_'ox(sQ)$
%
else i&(((int)Ney)@@) {
yincr!$ xincr*$
cleardevice()$ incr(sQ,xincr,yincr)$
put_'ox(sQ)$
% %
closegraph()$
%
void sca(int sQO"POP, &loat scx, &loat scy, int h, int N)
{
&or(int i!$i
8/15/2019 21919086 Graphics File
99/133
int sQO"POP$
initia(sQ)$
&loat scx,scy$ gotoxy(,)$
coutsx>>sy$
9hile((Neygetch())?VeV)
{
i&(((int)Ney)@) {
scy.$
scx.!$
cleardevice()$ sca(sQ,scx,scy,sx,sy)$
%
else i&(((int)Ney)!)
{ scy.!8.$
scx.!$
cleardevice()$
sca(sQ,scx,scy,sx,sy)$
% else i&(((int)Ney)@*)
{
scx.!8.$ scy.!$
cleardevice()$
sca(sQ,scx,scy,sx,sy)$
% else i&(((int)Ney)@@)
{
scx.$
scy.!$ cleardevice()$
sca(sQ,scx,scy,sx,sy)$ %
% closegraph()$
%
void scale_gen()
{
char Ney$ int sQO"POP$
initia(sQ)$
&loat scx,scy$
9hile((Neygetch())?VeV) {
i&(((int)Ney)@)
{
scy.$ scx.!$
cleardevice()$
sca(sQ,scx,scy,!,!)$
% else i&(((int)Ney)!)
8/15/2019 21919086 Graphics File
100/133
{
scy.!8.$
scx.!$ cleardevice()$
sca(sQ,scx,scy,!,!)$
%
else i&(((int)Ney)@*) {
scx.!8.$
scy.!$
cleardevice()$ sca(sQ,scx,scy,!,!)$
%
else i&(((int)Ney)@@)
{ scx.$
scy.!$
cleardevice()$
sca(sQ,scx,scy,!,!)$ %
%
closegraph()$
%
void main()
{
clrscr()$ int ch$
do
{
cout
8/15/2019 21919086 Graphics File
101/133
8/15/2019 21919086 Graphics File
102/133
3D 4;AN/
8/15/2019 21919086 Graphics File
103/133
disp(pyr)$
%
void rota(int pyrOPO3P, int pyrOPO3P)
{
cleardevice()$
cout
8/15/2019 21919086 Graphics File
104/133
{
pyrOiPO!PpyrOiPO!P$
pyrOiPOPpyrOiPOP$ pyrOiPOPpyrOiPOP$
%
rotate(pyr,pyr,d,axis)$
axaxis$ %
%
&or(int i!$i
8/15/2019 21919086 Graphics File
105/133
&or(int i!$i
8/15/2019 21919086 Graphics File
106/133
8/15/2019 21919086 Graphics File
107/133
AN4:AL:A/:NG 6 G=P4A /P;
#include
#include
#include#include
int main(void){ int gdriver -66, gmode, errorcode$
&loat x,x,y,y,x,y,dx,dy,d,t$
dou'le id,di$
void intensepix(&loat ,&loat ,dou'le)$ initgraph(=gdriver, =gmode, :c;tc'gi:)$
print&(:enter the end points o& line:)$
cin>>x>>y>>x>>y$
line(!+x,"!y,!+x,"!y)$ dxxx,dyyy$
id8(7po9((dx7dx+dy7dy),!.*))$
di7dx7id$
d7dydx$
xx$ yy$
getch()$
intensepix(x,y,!)$
intensepix(x,y+,di)$ intensepix(x,y,di)$
9hile(x td+dx$
d+7dy$ x++$ %
else
{
tddx$ d+7(dydx)$
x++,y++$
%
intensepix(x,y,t7id)$ intensepix(x,y+,dit7id)$
intensepix(x,y,di+t7id)$
%
getch()$%
void intensepix(&loat x,&loat y,dou'le d)
{ int in$
i&(d!.!)
in*$
i&((d
8/15/2019 21919086 Graphics File
108/133
i&((d."))
in$
i&(d>) in!$
putpixel(x+3!,"!y,in)$
%
8/15/2019 21919086 Graphics File
109/133
8/15/2019 21919086 Graphics File
110/133
,:DD*N /=;A'* *L:M:NA4:
8/15/2019 21919086 Graphics File
111/133
9hile(ptsONP.y ptsOMP.y)
i& ((M+)>(cnt)) M ! $
else
M++ $
return (ptsOMP.y) $%
void maNeedgerec(dcpt lo9er,dcpt upper,int ycomp,edge 7edge,edge 7edgesOP)
{ edge>dxperscan (&loat)(upper.xlo9er.x)8(upper.ylo9er.y) $
edge>xintersect lo9er.x $
i& (upper.yyupper upper.y $ else
edge>yupper upper.y $
insertedge(edgesOlo9er.yP,edge) $
%
void 'uildedgelist(int cnt,dcpt 7pts,edge 7edgesOP)
{
edge 7edge $
dcpt v, v $ int i, yprevptsOcntP.y $
v.x ptsOcntP.x $ v.y ptsOcntP.y $
&or(i!$i
8/15/2019 21919086 Graphics File
112/133
i&(planesOpoly_noPOP?!)
T(.!)7(planesOpoly_noPO!P7x7.!+planesOpoly_noPOP7y7.!+planesOpoly_noPO3P)8planesOpoly_noP
OP$ else
T3@2@$
i&(T>T'u&&erOxPOyP)
{ screenOxPOyPcolor$
T'u&&erOxPOyPT$
%
%
void &illscan(int scan,edge 7active, int color)
{ edge 7p,7p $
int i $
p active>next $
9hile(p) {
p p>next $
&or(ip>xintersect$ixintersect)$i++)
{ 87putpixel((int)i,scan,color) $78
checNW'u&&(i,scan,color)$ %
p p>next $
%%
void deletea&ter(edge 7Q)
{ edge 7p Q>next $
Q>next p>next $
&ree(p) $
%
void updateactivelist(int scan, edge 7active){
edge 7Qactive, 7pactive>next $ 9hile(p)
i& (scan > p>yupper)
{ p p>next $
deletea&ter(Q) $
%
else {
p>xintersect p>xintersect + p>dxperscan $
Q p $
p p>next $ %
%
void resortactivelist(edge 7active){
edge 7Q,7pactive>next $
active>next F100 $
9hile(p) {
8/15/2019 21919086 Graphics File
113/133
Q p>next $
insertedge(active,p) $
p Q $ %
%
void scan&ill(int cnt,dcpt 7pts, int color){
edge 7edgesO"!P,7active $
int i,scan $
&or(iymax$inext F100 $
% 'uildedgelist(cnt,pts,edges) $
active (edge 7)malloc(siTeo&(edge)) $
active>next F100 $
&or(scanymax$scan
8/15/2019 21919086 Graphics File
114/133
&loat 77temp$
&loat matrixO"PO"P$
&loat rad_angle$ &loat x,y,T,x,y,T,x3,y3,T3$
clrscr()$
matrixO!PO3P!$
matrixOPO3P!$ matrixOPO3P!$
matrixO3PO3P$
matrixO3PO!P!$
matrixO3POP!$ matrixO3POP!$
print&(:nter num'er o& polygons;:)$
scan&(:Bd:,=no_poly)$
temp(&loat77)malloc("7siTeo&(&loat))$ planes(&loat77)malloc(no_poly7siTeo&(&loat))$
polys(dcpt77)malloc(no_poly7siTeo&(dcpt))$
color(int7)malloc(no_poly7siTeo&(int))$
n(int7)malloc(no_poly7siTeo&(int))$ &or(i!$i
8/15/2019 21919086 Graphics File
115/133
planesOiPO!Py7(TT3)+y7(T3T)+y37(TT)$
87/78
planesOiPOPT7(xx3)+T7(x3x)+T37(xx)$ 8778
planesOiPOPx7(yy3)+x7(y3y)+x37(yy)$
87-78
planesOiPO3P()7x7(y7T3y37T)x7(y37Ty7T3)x37(y7Ty7T)$ %
&or(poly_no!$poly_no
8/15/2019 21919086 Graphics File
116/133
8/15/2019 21919086 Graphics File
117/133
"A'@ A'* D*4*'4:
8/15/2019 21919086 Graphics File
118/133
&loat tempO"PO"P$
&or(i!$i
8/15/2019 21919086 Graphics File
119/133
ttrans&ormO!PO3P-elx$
ttrans&ormOPO3P-ely$
ttrans&ormOPO3P-elT$updatetrans&orm(ttrans&orm)$
%
void scale(&loat Lx,&loat Ly,&loat LT)
{
&loat ttrans&ormO"PO"P$
int i,M$&or(i!$i
8/15/2019 21919086 Graphics File
120/133
midxgetmaxx()8$
midygetmaxy()8$
&or(i!$i
8/15/2019 21919086 Graphics File
121/133
int gd -66, gmode$
initgraph( =gd, =gmode, :c;tc'gi:)$
initialise()$
angle!.!*$
ch!$
9hile(ch?@){
cleardevice()$
initialise()$
i&(chVCV) rotate(angle,y)$
i&(chVUV)
rotate(7angle,y)$
i&(chVIV) rotate(angle,x)$
i&(chV4V)
rotate(7angle,x)$
i&(chV+V) scale(.!!*,.!!*,.!!*)$
i&(chVV)
scale(!.AA*,!.AA*,!.AA*)$
initialise()$
detect_sur&ace()$ o_proMect()$
&&lush(stdin)$
chgetch()$%
getch()$
closegraph()$
%
8/15/2019 21919086 Graphics File
122/133
8/15/2019 21919086 Graphics File
123/133
P;+x ">x >+y *>y 3>+T 2>T:)$
outtextxy(!,!,:Xie9 plane to9ards o'Mect T and a9ay x:)$
outtextxy(!,3!,:Xie9 point + to go close and to move a9ay:)$ do
{setcolor(!)$
dra9()$
i&(NeyV+V==TvpTprp>*)
Tprp+"$
i&(NeyVV==Tprp>!!!)
Tprp"$
i&(NeyVTV==Tvp
8/15/2019 21919086 Graphics File
124/133
roty(*.!)$
i&(NeyV3V)
rotT(*.!)$
i&(NeyV2V)
rotT(*.!)$
Tmax37-$
&or(i!$iTmax)
TmaxcorOiPOP$
setcolor(A)$dra9()$Neygetch()$
% 9hile(Ney?@)$
%
void dra9()
{
void dline(char,char)$
dline(!,)$
dline(!,3)$
dline(!,@)$
dline(*,2)$ dline(*,)$
dline(*,")$
dline(,3)$
dline(,")$
dline(",@)$
dline(@,2)$
dline(3,2)$ dline(,)$
%
void dline(char p,char p)
{ int x,x,y,y,d$
dTprpTvp$
xcorOpPO!P7d8(corOpPOPTprp)$
xcorOpPO!P7d8(corOpPOPTprp)$
ycorOpPOP7d8(corOpPOPTprp)$
ycorOpPOP7d8(corOpPOPTprp)$
line(x+ox,y+oy,x+ox,y+oy)$
%
void rotx(&loat d)
{ int i$ &loat y,T$
&loat cs,sn$
cscos(d7I58!)$
snsin(d7I58!)$
&or(i!$i
8/15/2019 21919086 Graphics File
125/133
TcorOiPOP7sn+corOiPOP7cs$
corOiPOPy$
corOiPOPT$
%
%
void roty(&loat d)
{
int i$
&loat x,T$ &loat cs,sn$ cscos(d7I58!)$
snsin(d7I58!)$
&or(i!$i
8/15/2019 21919086 Graphics File
126/133
8/15/2019 21919086 Graphics File
127/133
"*7:*; '=;8*
#include#include
#include
void 'eTier()$
void main(){
int driver,mode$
driver-66$ initgraph(=driver,=mode,:c;tc'gi:)$ 'eTier()$
%
void 'eTier(){
&loat pO3P,pO3P,p3O3P,p"O3P,tempO3P$
coutpO!P>>pOP>>pOP$ coutpO!P>>pOP>>pOP$
coutp3O!P>>p3OP>>p3OP$
cout>p"OP>>p"OP$
tempO!PpO!P$ tempOPpOP$ tempOPpOP$ cleardevice()$
&or(&loat t.!!$t
8/15/2019 21919086 Graphics File
128/133
8/15/2019 21919086 Graphics File
129/133
,*;M:4* '=;8*
#include
#include
#include
#include#include
#include
#include
struct pt
{
&loat x,y$
&loat mx,my$%$
struct pt g,g$
void main(){
&loat outx,outy$
&loat u$
&loat gxO"P,gyO"P,tempxO"P,tempyO"P$
coutg.x$ coutg.y$
coutg.x$ coutg.y$
coutg.mx$
coutg.my$ coutg.mx$
coutg.my$
int gdriver -66, gmode, errorcode$
initgraph(=gdriver, =gmode, :c;tc'gi:)$
gxO!Pg.x$
gxOPg.x$
gxOPg.mx$
gxO3Pg.mx$
gyO!Pg.y$
gyOPg.y$
gyOPg.my$ gyO3Pg.my$
tempxO!P 7(gxO!PgxOP) + gxOP + gxO3P$
tempxOP 37(gxO!PgxOP) 7gxOP gxO3P$ tempxOP gxOP$
8/15/2019 21919086 Graphics File
130/133
tempxO3P gxO!P$
tempyO!P 7(gyO!PgyOP) + gyOP + gyO3P$ tempyOP 37(gyO!PgyOP) 7gyOP gyO3P$
tempyOP gyOP$
tempyO3P gyO!P$
setcolor(-)$
line(!,"!,2"!,"!)$
setcolor(/01)$
line(3!,!,3!,"!)$ setcolor(456)$
&or(u!$u
8/15/2019 21919086 Graphics File
131/133
8/15/2019 21919086 Graphics File
132/133
"5/PL:N* '=;8*
#include #include
#include
#include
#include
int main(void)
{
int gdriver -66, gmode, errorcode$
&loat t,i,y,x,M,N$
int cxO!P,cyO!P,n$
87 initialiTe graphics and local
varia'les 78
initgraph(=gdriver, =gmode, :c;tc'gi:)$ line(3!,!,3!,"!)$
line(!,"!,2"!,"!)$
coutn$
&or(i$i>cyOiP$
%
coutcxO!P>>cyO!P>>cxOnP>>cyOnP$ &or(i3$i
8/15/2019 21919086 Graphics File
133/133