0% found this document useful (0 votes)
711 views2 pages

Aim: To Write A C Graphics Program For Translation of Rectangle

The document describes a C graphics program to translate a rectangle. It includes functions to draw a rectangle given coordinates, translate the rectangle by adding offsets to the coordinates, and a main function to get user input for the initial rectangle coordinates, draw the rectangle, translate it, and redraw it. The rectangle drawing function uses lines to connect the points of the rectangle. The translation function gets new x and y offsets from the user, clears the screen, adds the offsets to the original coordinates, and redraws the rectangle.

Uploaded by

Maisha Kéim
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
711 views2 pages

Aim: To Write A C Graphics Program For Translation of Rectangle

The document describes a C graphics program to translate a rectangle. It includes functions to draw a rectangle given coordinates, translate the rectangle by adding offsets to the coordinates, and a main function to get user input for the initial rectangle coordinates, draw the rectangle, translate it, and redraw it. The rectangle drawing function uses lines to connect the points of the rectangle. The translation function gets new x and y offsets from the user, clears the screen, adds the offsets to the original coordinates, and redraws the rectangle.

Uploaded by

Maisha Kéim
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

Yansi Keim || 01120703111

Aim: To write a C graphics program for translation of Rectangle


#include<stdio.h> #include<conio.h> #include<graphics.h> #include<process.h> #include<math.h> void RectAngle(int x,int y,int Height,int Width); void Translate(int x,int y,int Height,int Width); void main() { clrscr(); int gd=DETECT,gm; int x,y,Height,Width; initgraph(&gd,&gm,"C:\\TC\\BGI"); printf("Enter the First point for the Rectangle:"); scanf("%d%d",&x,&y); printf("Enter the Height&Width for the Rectangle:"); scanf("%d%d",&Height,&Width); RectAngle(x,y,Height,Width); getch(); cleardevice(); Translate(x,y,Height,Width); RectAngle(x,y,Height,Width); getch(); } void RectAngle(int x,int y,int Height,int Width) { line(x,y,x+Width,y); line(x,y,x,y+Height); line(x+Width,y,x+Width,y+Height); line(x,y+Height,x+Width,y+Height); }

Page 1

Yansi Keim || 01120703111


void Translate(int x,int y,int Height,int Width) { int Newx,Newy,a,b; printf("Enter the Transaction coordinates"); scanf("%d%d",&Newx,&Newy); cleardevice(); a=x+Newx; b=y+Newy; RectAngle(a,b,Height,Width); } Output

Page 2

You might also like