Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
5.0 kB
2
Indexable
Never

SCALLING

#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>

int gd=DETECT,gm;
void main()
{
	int sx,sy,x1,y1,x2,y2;
	printf("\nENTER THE  POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x1,&y1);
	printf("\nENTER THE OTHER TWO POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x2,&y2);
	printf("\nENTER THE SCALING FACTORS OF THE RECTANGLE\n");
	scanf("%d%d",&sx,&sy);
	initgraph(&gd,&gm,NULL);
	setcolor(4);
	rectangle(x1,y1,x2,y2);
	int x11,x12,y11,y12;
	x11=x1*sx;
	y11=y1*sy;
	x12=x2*sx;
	y12=y2*sy;
	setcolor(6);
	rectangle(x11,y11,x12,y12);
	getch();
	closegraph();
}
		
		
SHEARING


#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>

int gd=DETECT,gm;
void main()
{
	int shx,shy,x1,y1,x2,y2,i,j;
	printf("\nENTER THE  POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x1,&y1);
	printf("\nENTER THE OTHER TWO POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x2,&y2);
	printf("\nENTER SHEARING FACTORS OF THE RECTANGLE\n");
	scanf("%d%d",&shx,&shy);
	initgraph(&gd,&gm,NULL);
	setcolor(4);
	line(x1,y1,x2,y1);
	line(x2,y1,x2,y2);
	line(x2,y2,x1,y2);
	line(x1,y2,x1,y1);
	int x11,x12,y11,y12;
	for(i=x1;i<=x2;i++)
		for(j=y1;i<=y2;j++)
		{
		
			x11=x1+shx*y1;
			y11=y1+shy*x1;
			x12=x2+shx*y2;
			y12=y2+shy*x2;
			setcolor(i%8);
			line(x11,y11,x12,y11);
			line(x12,y11,x12,y12);
			line(x12,y12,x11,y12);
			line(x11,y12,x11,y11);
		}
getch();
closegraph();
}
		
		
TRANSCLET


#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>

int gd=DETECT,gm;
void main()
{
	int tx,ty,x1,y1,x2,y2;
	printf("\nENTER THE  POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x1,&y1);
	printf("\nENTER THE OTHER TWO POINTS OF THE ORIGINAL RECTANGLE\n");
	scanf("%d%d",&x2,&y2);
	printf("\nENTER  TRANSLATION FACTORS OF THE RECTANGLE\n");
	scanf("%d%d",&tx,&ty);
	initgraph(&gd,&gm,NULL);
	setcolor(4);
	rectangle(x1,y1,x2,y2);
	int x11,x12,y11,y12;
	x11=x1+tx;
	y11=y1+ty;
	x12=x2+tx;
	y12=y2+ty;
	setcolor(6);
	rectangle(x11,y11,x12,y12);
	getch();
	closegraph();
}


BCDA


#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int r,x,y,i=1,p;
int xc,yc,f;
int gd=DETECT,gm;
void main()
{
	printf("\nENTER THE CENTER POINTS OF THE CIRCLE\n");
	scanf("%d%d",&xc,&yc);
	printf("\nENTER THE RADIUS OF THE CIRCLE\n");
	scanf("%d",&r);
	printf("\nENTER THE STEPS \n");
	scanf("%d",&f);
	x=0,y=r,p=3-2*r;
	initgraph(&gd,&gm,NULL);
	putpixel(xc+x,yc+y,i);
	putpixel(xc-x,yc+y,i);
	putpixel(xc+x,yc-y,i);
	putpixel(xc-x,yc-y,i);
	while(x<=y)
	{
		if(p<0)
		{

			p=p+(4*x)+6;
			x=x+1;
		}
		else
		{
	
			p=p+4*x-4*y+10;
			x=x+1;
			y=y-1;
		}
		delay(100);
		putpixel(xc+x,yc+y,i%8);
		putpixel(xc-x,yc+y,i%8);
		putpixel(xc+x,yc-y,i%8);
		putpixel(xc-x,yc-y,i%8);
		putpixel(xc+y,yc+x,i%8);
		putpixel(xc-y,yc+x,i%8);
		putpixel(xc+y,yc-x,i%8);
		putpixel(xc-y,yc-x,i%8);
		i++;
	}
	getch();
	closegraph();
}



BLDA 


#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int gd=DETECT,gm;
void main()
{
	int i=1,x1,y1,p,x,y,dx,dy;
	printf("\nEnter initial points\n");
	scanf("%d%d",&x,&y);
	printf("\nEnter end points\n");
	scanf("%d%d",&x1,&y1);
	dx=x1-x;
	dy=y1-y;
	p=(2*dy)-dx;
	initgraph(&gd,&gm,NULL);
	while(i<=dx)
	{
		if(p>0)
		{
			x=x+1;
			y=y+1;
			p=p+(2*dy)-2*dx;
		}
			else
			{
				x=x+1;
				p=p+2*dy;
			}
		
		putpixel(x,y,i);
		i++;
	}
	getch();
	closegraph();
}
	


MID-POINT 


#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int r,x,y,i=1,p;
int xc,yc,f;
int gd=DETECT,gm;
void main()
{
	printf("\nENTER THE CENTER POINTS OF THE CIRCLE\n");
	scanf("%d%d",&xc,&yc);
	printf("\nENTER THE RADIUS OF THE CIRCLE\n");
	scanf("%d",&r);
	printf("\nENTER THE INCREEMENTAL ANGLE OF THE  CIRCLE\n");
	scanf("%d",&f);
	x=0,y=r,p=1-r;
	initgraph(&gd,&gm,NULL);
	putpixel(xc+x,yc+y,i);
	putpixel(xc-x,yc+y,i);
	putpixel(xc+x,yc-y,i);
	putpixel(xc-x,yc-y,i);
	while(x<=y)
	{
		if(p<0)
		{
			x=x+1;
			p=p+2*x+1;
		}
		else
		{
			x++;
			y--;
			p=p+2*x-2*y+1;
		}
		delay(100);
		putpixel(xc+x,yc+y,i%8);
		putpixel(xc-x,yc+y,i%8);
		putpixel(xc+x,yc-y,i%8);
		putpixel(xc-x,yc-y,i%8);
		putpixel(xc+y,yc+x,i%8);
		putpixel(xc-y,yc+x,i%8);
		putpixel(xc+y,yc-x,i%8);
		putpixel(xc-y,yc-x,i%8);
		i++;
	}
	getch();
	closegraph();
}
	



DDA LINE 




#include<stdio.h>
#include<graphics.h>
#include<stdlib.h>
int gd=DETECT,gm;
void main()
{
	int i=1,x,y,x1,y1,length,dx,dy,ux,uy;
	printf("\nEnter initial points\n");
	scanf("%d%d",&x,&y);
	printf("\nEnter end points\n");
	scanf("%d%d",&x1,&y1);
	dx=x1-x;
	dy=y1-y;
	if(dx>dy)
	{
		length=dx;
	}
	else
	{
		length=dy;
	}
	ux=dx/length;
	uy=dy/length;
	initgraph(&gd,&gm,NULL);
	while(i<=length)
	{
		putpixel(x,y,i);
		x=x+ux;
		y=y+uy;
		i++;
	}
	getch();
	closegraph();
}
	

	

CLIPPING 	
Leave a Comment