0% found this document useful (0 votes)
10 views39 pages

Graphics College 01 Note

The document contains a series of C programs that demonstrate various graphics drawing techniques using the graphics.h library. Programs include drawing shapes like squares, rectangles, triangles, circles, and more complex figures like human faces and houses, as well as implementing algorithms for line and circle drawing, filling areas, and clipping lines. Each program is structured with initialization, drawing commands, and a closing sequence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views39 pages

Graphics College 01 Note

The document contains a series of C programs that demonstrate various graphics drawing techniques using the graphics.h library. Programs include drawing shapes like squares, rectangles, triangles, circles, and more complex figures like human faces and houses, as well as implementing algorithms for line and circle drawing, filling areas, and clipping lines. Each program is structured with initialization, drawing commands, and a closing sequence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 39

1. Write a program to draw Square, Rectangle, Triangle and Circle.

Program :-
#include<stdio.h>
#include <conio.h>
#include <graphics.h>
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, “..//bgi”);
//Square
line(400,300,550,300);
line(400,300,400,450);
line(550,300,550,450);
line(400,450,550,450);
//Rectangle
line(400,100,600,100);
line(400,100,400,200);
line(400,200,600,200);
line(600,100,600,200);
//Triangle
line(140,290,50,450);
line(140,290,230,450);
line(50,450,230,450);
//Circle
circle(140,150,80);
getch();
closegraph();
}
Input and Output Section :-
2. Write a program to draw a Human Face.
Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
Void main ()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
circle(250, 200, 100);
circle(220, 170, 10);
circle(280, 170, 10);
arc(250, 200, 200, 340, 40);
line(250, 180, 250, 220);
getch();
closegraph();
}

Input and Output Section :-


3. Write a program to draw a House.
Program :-
#include <stdio.h>
#include <conio.h>
#include<graphics,h>
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
rectangle(150, 200, 350, 400);
rectangle(200, 300, 250, 400);
line(150, 200, 250, 100);
line(250, 100, 350, 200);
rectangle(275, 250, 325, 300);
getch ();
closegraph ();
}

Input and Output Section :-


4. Write a program to draw a Car.
Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
rectangle(100, 200, 300, 250);
rectangle(150, 150, 250, 200);
circle(150, 260, 15);
circle(250, 260, 15);
getch();
closegraph();
}
Input and Output Section :-

5. Write a program to draw a line using DDA line drawing algorithm.


Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
clrscr();
int gd = DETECT, gm,i;
initgraph(&gd,&gm,"..\\bgi ");
setbkcolor(GREEN);
int x1,y1,x2,y2;
float x, y, dx, dy, length;
printf("Enter x1 & y1");
scanf("%d %d",&x1,&y1);
printf("Enter x2 &y2");
scanf("%d %d",&x2,&y2);
dx =(float)(x2 - x1);
dy =(float)(y2 - y1);
if(dx>=dy){
length=dx;
}
else
{
length=dy;
}
dx=dx/length;
dy=dy/length;
x=x1+0.5;
y=y1+0.5;
i=1;
while(i<=length)
{
putpixel(x,y,RED);
x=x+dx;
y=y+dy;
i=i+1;
delay(100);
}
getch();
}
Input and output Section :-

6. Write a program to draw a line using Bresenham’s line drawing


algorithm.
Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
void main()
{
int gd=DETECT, gm, x0, y0, x1, y1;
int dx, dy, p, x, y;
initgraph(&gd, &gm, "..\\bgi");
printf("Enter co-ordinates of first point: ");
scanf("%d%d", &x0, &y0);
printf("Enter co-ordinates of second point: ");
scanf("%d%d", &x1, &y1);
dx=abs(x1-x0);
dy=abs(y1-y0);
x=x0;
y=y0;
p=2*dy-dx;
while(x<x1)
{
if(p<0)
{
putpixel(x,y,7);
p=p+2*dy;
}
Else
{
putpixel(x,y,7);
y=y+1;
p=p+2*dy-2*dx;
}
x=x+1;
delay(50);
}
getch();
}

Input and Output Section :-


7. Write a program to draw a circle using Bresenham’s circle drawing
algorithm.
Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void BresenhamCircle(int xc,int yc, int r)
{
int x,y,dp;
x=0;
y=r;
dp=3-(2*r);
for(x=0;x<=y;x++)
{
putpixel(xc+x,yc-y,YELLOW);
putpixel(xc-x,yc-y,RED);
putpixel(xc+x,yc+y,GREEN);
putpixel(xc-x,yc+y,BLUE);
putpixel(xc+y,yc-x,BROWN);
putpixel(xc-y,yc-x,BLACK);
putpixel(xc+y,yc+x,CYAN);
putpixel(xc-y,yc+x,MAGENTA);
delay(50);
if(dp<0){
dp=dp+(4 * x)+6;
}
else{
y=y-1;
dp=dp +4 *(x-y)+10;
}
}
}
void main()
{
int xc,yc,r;
int gd=DETECT,gm;
initgraph(&gd,&gm,"..\\bgi ");
clrscr();
printf("\nEnter the co-ordinates of center : ");
scanf("%d %d",&xc,&yc);
printf("\nEnter the radius: ");
scanf("%d",&r);
BresenhamCircle(xc,yc,r);
getch();
closegraph();
}

Input and Output Section :-

8. Write a program to draw a circle using Midpoint circle drawing


algorithm.
Program :-
#include <stdio.h>
#include <conio.h>
#include<graphics.h>
void drawCircle(int xc, int yc, int r)
{
int x = 0, y = r;
int p = 1 - r;
while (x <= y) {
putpixel(xc + x, yc + y, RED);
putpixel(xc - x, yc + y, YELLOW);
putpixel(xc + x, yc - y, GREEN);
putpixel(xc - x, yc - y, BLUE);
putpixel(xc + y, yc + x, CYAN);
putpixel(xc - y, yc + x, WHITE);
putpixel(xc + y, yc - x, BROWN);
putpixel(xc - y, yc - x, MAGENTA);
if (p < 0)
p += 2 * x + 3;
else
{
p += 2 * (x - y) + 5;
y--;
}
x++;
}
}
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
drawCircle(250, 250, 100);
getch();
closegraph();
}
Input and Output Section :-

9. Write a program to draw an Ellipse using Ellispse generation algorithm.


Program :-
#include <stdio.h>
#include <conio.h>
#include<graphics.h>
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
ellipse(250, 250, 0, 360, 100, 50); // center (250,250), x-radius=100, y-radius=50
getch();
closegraph();
}

Input and Output Section :-

10. Write a program to draw an area using Flood fill algorithm.


Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void flood(int x, int y, int n_color, int o_color)
{
int current=getpixel(x,y);
if(current == o_color)
{
putpixel(x, y, n_color);
flood(x + 1, y, n_color, o_color);
flood(x-1, y , n_color, o_color);
flood(x , y+1, n_color, o_color);
flood(x, y - 1, n_color, o_color);
}
}
void main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
// Rectangle function
setcolor(13);
rectangle(50, 50, 75, 100);
rectangle(75,50,100,100);
rectangle(100,50,125,100);
rectangle(150,100,125,50);
// Function calling
flood(60, 60, 1,0);
flood(80, 80, 4,0);
flood(110, 90, 14,0);
flood(130, 60, 2,0);
getch();
closegraph();
}
Input and Output Section :-

11. Write a program to draw an area using Boundary fill algorithm.


Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void boundaryFill8(int x, int y, int f_color,int b_color)
{
int current=getpixel(x,y);
if(current!= b_color && current != f_color)
{
putpixel(x, y, f_color);
boundaryFill8(x + 1, y, f_color, b_color);
boundaryFill8(x, y + 1, f_color, b_color);
boundaryFill8(x - 1, y, f_color, b_color);
boundaryFill8(x, y - 1, f_color, b_color);
boundaryFill8(x - 1, y - 1, f_color, b_color);
boundaryFill8(x - 1, y + 1, f_color, b_color);
boundaryFill8(x + 1, y - 1, f_color, b_color);
boundaryFill8(x + 1, y + 1, f_color, b_color);
}
}
void main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "..\\bgi");
// Rectangle function
rectangle(50, 50, 75, 100);
rectangle(75,50,100,100);
rectangle(100,50,125,100);
rectangle(125,50,150,100);
// Function calling
boundaryFill8(60, 60, 1,15);
boundaryFill8(80, 80, 4,15);
boundaryFill8(110, 90, 14,15);
boundaryFill8(130, 60, 2,15);
//color
getch();
closegraph();
}

Input and Output Section :-

12. Write a program to clip a line using cohen and Sutherland line clippling
algorithm.
Program :-
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
#include<dos.h>
void main()
{
int rcode_begin[4]={0,0,0,0},rcode_end[4]={0,0,0,0},region_code[4];
int W_xmax,W_ymax,W_xmin,W_ymin,flag=0;
float slope;
int x,y,x1,y1,i, xc,yc;
int gr=DETECT,gm;
initgraph(&gr,&gm,"..\\bgi ");
printf("\n****** Cohen Sutherlsnd Line Clipping algorithm ***********");
printf("\n Now, enter XMin, YMin =");
scanf("%d %d",&W_xmin,&W_ymin);
printf("\n First enter XMax, YMax =");
scanf("%d %d",&W_xmax,&W_ymax);
printf("\n Please enter intial point x and y= ");
scanf("%d %d",&x,&y);
printf("\n Now, enter final point x1 and y1= ");
scanf("%d %d",&x1,&y1);
cleardevice();
rectangle(W_xmin,W_ymin,W_xmax,W_ymax);
line(x,y,x1,y1);
line(0,0,600,0);
line(0,0,0,600);
if(y>W_ymax)
{
rcode_begin[0]=1; // Top
flag=1 ;
}
if(y<W_ymin)
{
rcode_begin[1]=1; // Bottom
flag=1;
}
if(x>W_xmax)
{
rcode_begin[2]=1; // Right
flag=1;
}
if(x<W_xmin)
{
rcode_begin[3]=1; //Left
flag=1;
}
//end point of Line
if(y1>W_ymax)
{
rcode_end[0]=1; // Top
flag=1;
}
if(y1<W_ymin)
{
rcode_end[1]=1; // Bottom
flag=1;
}
if(x1>W_xmax)
{
rcode_end[2]=1; // Right
flag=1;
}
if(x1<W_xmin)
{
rcode_end[3]=1; //Left
flag=1;
}
if(flag==0)
{
printf("No need of clipping as it is already in window");
}
flag=1;
for(i=0;i<4;i++)
{
region_code[i]= rcode_begin[i] && rcode_end[i] ;
if(region_code[i]==1)
flag=0;
}
if(flag==0)
{
printf("\n Line is completely outside the window");
}
else{
slope=(float)(y1-y)/(x1-x);
if(rcode_begin[2]==0 && rcode_begin[3]==1) //left
{
y=y+(float) (W_xmin-x)*slope ;
x=W_xmin;
}
if(rcode_begin[2]==1 && rcode_begin[3]==0) // right
{
y=y+(float) (W_xmax-x)*slope ;
x=W_xmax;
}
if(rcode_begin[0]==1 && rcode_begin[1]==0) // top
{
x=x+(float) (W_ymax-y)/slope ;
y=W_ymax;
}
if(rcode_begin[0]==0 && rcode_begin[1]==1) // bottom
{
x=x+(float) (W_ymin-y)/slope ;
y=W_ymin;
}
// end points
if(rcode_end[2]==0 && rcode_end[3]==1) //left
{
y1=y1+(float) (W_xmin-x1)*slope ;
x1=W_xmin;
}
if(rcode_end[2]==1 && rcode_end[3]==0) // right
{
y1=y1+(float) (W_xmax-x1)*slope ;
x1=W_xmax;
}
if(rcode_end[0]==1 && rcode_end[1]==0) // top
{
x1=x1+(float) (W_ymax-y1)/slope ;
y1=W_ymax;
}
if(rcode_end[0]==0 && rcode_end[1]==1) // bottom
{
x1=x1+(float) (W_ymin-y1)/slope ;
y1=W_ymin;
}
}
delay(10000);
clearviewport();
rectangle(W_xmin,W_ymin,W_xmax,W_ymax);
line(0,0,600,0);
line(0,0,0,600);
setcolor(RED);
line(x,y,x1,y1);
getch();
closegraph();
}

Input and Output Section :-

13. Write a program menu driven to show all the standards of 2D


reflection.
Program:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
int x[20], y[20], X[20], Y[20], a, b, n;
void output(int n);
void reflection_x_axis(int n);
void reflection_y_axis(int n);
void reflection_origin(int n);
void reflection_yETngtvx(int n);
void reflection_yETpstvx(int n);
int main()
{
int gd=DETECT, gm, i, j, ch, s, r, tx, ty, sx, sy, shx, shy, c;
float theta;
//clrscr();
initgraph(&gd,&gm,"..\\bgi");
printf("****** 2-D Transformation ******");
printf("\nEnter how many co-ordinate:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter Co-ordinate No %d :",i);
scanf("%d%d", &x[i],&y[i]);
}
do
{
a=getmaxx()/2;
b=getmaxy()/2;
line(a,0,a,2*b);
line(0,b,2*a,b);
setcolor(GREEN);
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+x[i],b-y[i],a+x[j],b-y[j]);
}
else
{
line(a+x[i],b-y[i],a+x[1],b-y[1]);
}
}
printf("\n 1.Reflection w.r.t. x-axis:");
printf("\n 2.Reflection w.r.t. y-axis:");
printf("\n 3.Reflection w.r.t. origin:");
printf("\n 4.Reflection w.r.t. y=x:");
printf("\n 5.Reflection w.r.t y=-x");
printf("\n 6.exit:");
printf("\nEnter Your Choice for Transformation:::: ");
scanf("%d", &ch);
switch(ch)
{
case 1:
clrscr();
reflection_x_axis(n);
output(n);
break;
case 2:
clrscr();
reflection_y_axis(n);
output(n);
break;
case 3:
clrscr();
reflection_origin(n);
output(n);
break;
case 4:
clrscr();
reflection_yETpstvx(n);
output(n);
break;
case 5:
clrscr();
reflection_yETngtvx(n);
output(n);
break;
default:
printf("wrong chooise::!!!");
}
}
while(ch!=6);
getch();
closegraph();
return 0;
}
void output(int n)
{
setcolor(RED);
int i,j;
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+X[i],b-Y[i],a+X[j],b-Y[j]);
}
else
{
line(a+X[i],b-Y[i],a+X[1],b-Y[1]);
}
}
}
void reflection_x_axis(int n)
{
for(int i=1;i<=n;i++)
{
X[i]=x[i];
Y[i]=-y[i];
}
}
void reflection_y_axis(int n)
{
for(int i=1;i<=n;i++)
{
X[i]=-x[i];
Y[i]=y[i];
}
}
void reflection_origin(int n)
{
for(int i=1;i<=n;i++)
{
X[i]=-x[i];
Y[i]=-y[i];
}
}
void reflection_yETngtvx(int n)
{
for(int i=1;i<=n;i++)
{
X[i]=-y[i];
Y[i]=-x[i];
}
}
void reflection_yETpstvx(int n)
{
for(int i=1;i<=n;i++)
{
X[i]=y[i];
Y[i]=x[i];
}
}
Write a program to perform the following transformation on a polygon (menu driven
program)
(i) Rotation with respect to an arbitrary point.
(ii) Translation with respect to origin.
Program :-
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
int x[20], y[20], X[20], Y[20], a, b, n;
void output(int n);
void translation(int tx,int ty);
void rotation_arbitary(float theta);
int main()
{
int gd=DETECT, gm, i, j, ch, s, r, tx, ty, sx, sy, shx, shy, c;
float theta;
//clrscr();
initgraph(&gd,&gm,"..\\bgi");
printf("****** 2-D Transformation ******");
printf("\nEnter how many co-ordinate:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter Co-ordinate No %d :",i);
scanf("%d%d", &x[i],&y[i]);
}
do
{
a=getmaxx()/2;
b=getmaxy()/2;
line(a,0,a,2*b);
line(0,b,2*a,b);
setcolor(GREEN);
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+x[i],b-y[i],a+x[j],b-y[j]);
}
else
{
line(a+x[i],b-y[i],a+x[1],b-y[1]);
}
}
printf("\n 1.Translation:");
printf("\n 2.Rotaion w.r.t. arbitary:");
printf("\n 3.exit:");
printf("\nEnter Your Choice for Transformation:::: ");
scanf("%d", &ch);
switch(ch)
{
case 1:
clrscr();
printf("\nEnter translating factor:");
scanf("%d%d",&tx,&ty);
translation(tx,ty);
output(n);
break;
case 2:
clrscr();
printf("\nEnter the angle of rotation:");
scanf("%f",&theta);
rotation_arbitary(theta);
output(n);
break;
case 3:
break;
default:
printf("wrong chooise::!!!");
}
}
while(ch!=3);
getch();
closegraph();
return 0;
}
void output(int n)
{
setcolor(RED);
int i,j;
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+X[i],b-Y[i],a+X[j],b-Y[j]);
}
else
{
line(a+X[i],b-Y[i],a+X[1],b-Y[1]);
}
}
}
void translation(int tx,int ty)
{
for(int i=1;i<=n;i++)
{
X[i]=x[i]+tx;
Y[i]=y[i]+ty;
}
}
void rotation_arbitary(float theta){
int xr,yr;
printf("Enter the fixed point: \n");
scanf("%d%d",&xr,&yr);
theta=(3.14*theta)/180.0;
for(int i=1;i<=n;i++)
{
X[i]=xr+((x[i]-xr)*cos(theta))-((y[i]-yr)*sin(theta));
Y[i]=yr+((x[i]-xr)*sin(theta))+((y[i]-yr)*cos(theta));
}
}
Write a program to implement 2D scaling of a rectangle with respect to origin and
arbitrary point.
Program:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
int x[20], y[20], X[20], Y[20], a, b, n;
void output(int n);
void scalling_origin(int sx,int sy);
void scalling_arbitary(int sx,int sy);
int main()
{
int gd=DETECT, gm, i, j, ch, s, r, tx, ty, sx, sy, shx, shy, c;
float theta;
//clrscr();
initgraph(&gd,&gm,"..\\bgi");
printf("****** 2-D Transformation ******");
printf("\nEnter how many co-ordinate:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("Enter Co-ordinate No %d :",i);
scanf("%d%d", &x[i],&y[i]);
}
do
{
a=getmaxx()/2;
b=getmaxy()/2;
line(a,0,a,2*b);
line(0,b,2*a,b);
setcolor(GREEN);
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+x[i],b-y[i],a+x[j],b-y[j]);
}
else
{
line(a+x[i],b-y[i],a+x[1],b-y[1]);
}
}
printf("\n 1.Scalling with respect to origin:");
printf("\n 2.Scalling with respect to arbitary:");
printf("\n 3.exit:");
printf("\nEnter Your Choice for Transformation:::: ");
scanf("%d", &ch);
switch(ch)
{
case 1:
clrscr();
printf("\n Enter scalling Factor:");
scanf("%d%d",&sx,&sy);
scalling_origin(sx,sy);
output(n);
break;
case 2:
clrscr();
printf("\n Enter scalling Factor:");
scanf("%d%d",&sx,&sy);
scalling_arbitary(sx,sy);
output(n);
break;
case 3:
break;
default:
printf("wrong chooise::!!!");
}
}
while(ch!=3);
getch();
closegraph();
return 0;
}
void output(int n)
{
setcolor(RED);
int i,j;
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+X[i],b-Y[i],a+X[j],b-Y[j]);
}
else
{
line(a+X[i],b-Y[i],a+X[1],b-Y[1]);
}
}
}
void scalling_origin(int sx,int sy)
{
int i;
for(i=1;i<=n;i++)
{
X[i]=x[i]*sx;
Y[i]=y[i]*sy;
}
}
void scalling_arbitary(int sx,int sy) {
int i,xf,yf;
printf("Enter fixed point:");
scanf("%d%d",&xf,&yf);
for(i=1;i<=n;i++)
{
X[i]=xf+(x[i]-xf)*sx;
Y[i]=yf+(y[i]-yf)*sy;
}
}
Write a program to implement 2D shearing of a triangle with respect to X -axis and Y-axis.
Program:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<math.h>
#include<stdlib.h>
int x[20], y[20], X[20], Y[20], a, b, n;
void output(int n);
void shearing_x_axis(int shx);
void shearing_y_axis(int shy);
int main()
{
int gd=DETECT, gm, i, j, ch, s, r, tx, ty, sx, sy, shx, shy, c;
float theta;
//clrscr();
initgraph(&gd,&gm,"..\\bgi");
printf("****** 2-D Transformation ******");
printf("\nEnter how many co-ordinate:");
scanf("%d",&n);
for(i=1;i<=n;i++){
printf("Enter Co-ordinate No %d :",i);
scanf("%d%d", &x[i],&y[i]);
}
do
{
a=getmaxx()/2;
b=getmaxy()/2;
line(a,0,a,2*b);
line(0,b,2*a,b);
setcolor(GREEN);
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+x[i],b-y[i],a+x[j],b-y[j]);
}
else
{
line(a+x[i],b-y[i],a+x[1],b-y[1]);
}
}
printf("\n 1.shearing w.r.t. x-axis:");
printf("\n 2.shearing w.r.t. y-axis:");
printf("\n 3.exit:");
printf("\nEnter Your Choice for Transformation:::: ");
scanf("%d", &ch);
switch(ch)
{
case 1:
clrscr();
printf("\n*************************************************");
printf("\nEnter the shearing Factor:");
scanf("%d",&shx);
shearing_x_axis(shx);
output(n);
break;
case 2:
clrscr();
printf("\n*************************************************");
printf("\nEnter the shearing Factor:");
scanf("%d",&shy);
shearing_y_axis(shy);
output(n);
break;
case 3:
break;
default:
printf("wrong chooise::!!!");
}
}
while(ch!=3);
getch();
closegraph();
return 0;
}
void output(int n)
{
setcolor(RED);
int i,j;
for(i=1;i<=n;i++)
{
j=i+1;
if(i<n)
{
line(a+X[i],b-Y[i],a+X[j],b-Y[j]);
}
else
{
line(a+X[i],b-Y[i],a+X[1],b-Y[1]);
}
}
}
void shearing_x_axis(int shx)
{
for(int i=1;i<=n;i++)
{
X[i]=x[i]+y[i]*shx;
Y[i]=y[i];
}
}
void shearing_y_axis(int shy)
{
for(int i=1;i<=n;i++)
{
X[i]=x[i];
Y[i]=x[i]*shy+y[i];
}
}

You might also like