Wednesday 9 November 2011

Scaling in Computer Graphics

#include
#include
#include
#include
#include

int x1,y1,x2,y2,x3,y3,mx,my;
void draw();
void scale();
void main()
{
int gd=DETECT,gm;
int c;
initgraph(&gd,&gm," ");
printf("Enter the 1st point for the triangle:");
scanf("%d%d",&x1,&y1);
printf("Enter the 2nd point for the triangle:");
scanf("%d%d",&x2,&y2);
printf("Enter the 3rd point for the triangle:");
scanf("%d%d",&x3,&y3);
draw();
scale();
}

void draw()
{
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
}
void scale()
{
int x,y,a1,a2,a3,b1,b2,b3;
int mx,my;
printf("Enter the scalling coordinates");
scanf("%d%d",&x,&y);
mx=(x1+x2+x3)/3;
my=(y1+y2+y3)/3;
cleardevice();
a1=mx+(x1-mx)*x;
b1=my+(y1-my)*y;
a2=mx+(x2-mx)*x;
b2=my+(y2-my)*y;
a3=mx+(x3-mx)*x;
b3=my+(y3-my)*y;
line(a1,b1,a2,b2);
line(a2,b2,a3,b3);
line(a3,b3,a1,b1);
draw();
getch();
}


Buy me a Cup of Coffee








MONIKA YADAV (MCA),
Software Engineer,
www.NotesGuru.in, Indore

ROHIT KESHRIYA (MCA),
Software Engineer,
www.NotesGuru.in, Indore

For guest faculty Contact us on following E-mail ID:

monikay.aerosoft@gmail.com
monikay.aerosoft@rediffmail.com
monikay.aerosoft@yahoo.com
monikay.aerosoft@hotmail.com
rohit.aerosoft@gmail.com
rohit.aerosoft@rediffmail.com
rohit.aerosoft@yahoo.com
rohit.aerosoft@hotmail.com

Note: We have been used search engines for gathering content.



















Your Ad Here







free counters

No comments:

Post a Comment