0% found this document useful (0 votes)
46 views14 pages

CGR Microproject2

Uploaded by

spideyjod15
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)
46 views14 pages

CGR Microproject2

Uploaded by

spideyjod15
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/ 14

A

MICRO PROJECT REPORT

ON
“2D SCALING”

SUBMITTED BY –

Sr. No. Name of Student Roll No.


1 Rohini Rajendra Mali. 25

2 Diksha Shivkumar Chougule. 26

3 Varun Sharad patil. 27

UNDER THE GUIDANCE OF


Mr.Suraj Jamadar

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


SANJAY GHODAWAT POLYTECHNIC, ATIGRE
ACADEMIC YEAR: 2024-25
Certificate
This is to certify that the Micro project work entitled

“2D SCALING”

Has been successfully completed by

In fulfillment for the

Diploma in Computer Science &Engineering

Maharashtra State Board of Technical Education

During the academic year 2024-25 under the guidance of

Mr.Suraj
Jamadar. Mr. S. V. Chavan

Project Guide H.O. D

Mr. V. V. Giri
Principal
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

Program Code – CW-3-k

Course Name – CGR

Course Code -

313001

Project Title

“2D SCALING”

Micro
Sr. Roll Enrollment Exam
Name of Student Project Total
No. No. No. Seat No.
Marks

G I 6+4 = 10

1 Rohini Rajendra 2116440348


Mali.
2 Diksha Shivkumar 2116440351
Chougule.

3 Varun Sharad Patil. 2116440352

Mr. Suraj Jamadar.

Course Faculty & Signature


Program Name – Computer Science & Engineering Program Code – CW-3-k

Course Name –CGR Course Code – 313001

Project Title – “2D SCALING”


Course Outcomes (CO), Practical Outcomes (PRO’s) and Unit Outcomes
(UOs) Mapping

PRO’s
COs UOs
Mapping

PRO’s Sr. No.


MICRO PROJECT DIARY

Sr.
From Date to Date Activity Performed
No.

10

11
INDEX

Sr.
CONTENT Page No.
No.

1 Abstract 1

2 Introduction 2

3 Algorithm 3

4 Program 4

5 Output 6

6 Conclusion 7

7 Reference 7
Abstract

The provided C code utilizes the Turbo C graphics library to create a project on 2d
scalling. 2D Scaling in Computer Graphics involves resizing objects or coordinate
systems in a 2D plane. It allows us to change the size of each point in the object or
coordinate system by applying scaling factors in the x and y directions.

To perform 2D scaling, we utilize scaling factors: sx for the x-axis and sy for the
y-axis. These factors determine how much each coordinate should be scaled along its
respective axis.
Introduction

 This is a C program that creates a 2D scaling using the graphics.h header file. The program
initializes the graphics system by loading the passed graphics driver and changing the system
into graphics mode. it allows us to change the size of each point in the object or coordinate
system by applying scaling factors in the x and y directions. To perform 2D scaling, we utilize
scaling factors: sx for the x-axis and sy for the y-axis. I
 nitial coordinates of the object O = (Xold, Yold)
 Scaling factor for X-axis = Sx
 Scaling factor for Y-axis = Sy
 New coordinates of the object O after scaling = (Xnew, Ynew)

This scaling is achieved by using the following scaling equations-


 Xnew = Xold x Sx
 Ynew = Yold x Sy
The program repeats above steps until user presses any key on keyboard. The provided C code
demonstrates a basic graphical animation using the Turbo C graphics library. Through this code, one
gains insight into the foundational aspects of graphical programming, particularly in the context of
Turbo C's graphics library.
ALGORITHM

Step 1 : START.
Step 2 : Initialize graphics using `initgraph`.
Step 3 : set the initial values for graphics driver(‘gd’)and graphics mode(`gm`).
Step 4 : Declare integer type variable n, x[100] ,y[100] and int i. And also declare sfx and sfy
variable of float type.
Step 5 : Take two functions namely:1)Void draw()

2)Void scale()

Step 6:Take a main function and inside it take a number of sides for a rectangle from user,
and also take a co-ordinates of x and y for each point. Clear the screen using `cleardevice`.
Step 7: Taking a fro loop which will execute
until the condition appers to be false.Taking the
scaling factors from user.
Step 8 : Set color(CYAN) and calling the
function draw() and scale().Again setting a color
which will be the inside shape to (YELLOW).
And again calling the function draw().
Step 9 : Taking a function Void draw() inside it we will take a for loop for
drawing a object on output screen taking the coordinates which we have already
taken.
Step 10 : Taking a function namely void scale() inside it for loop to make the
coordinates properly aligned.closing the scale function.
Step 11 :Close the graphics using closegraph.

Step 12: STOP.


PROGRAM

#include <graphics.h>
#include <math.h>
#include <conio.h>
Int gd=DETECT,gm;
Int n,x[100], y[100],i;
Float sfx,sfy;
Void draw();
Void scale();

Void main()
{
Clrscr();
Printf(“Enter a number of sides :”)
Scanf(“%d”,&n);
Printf(“Enter co-ordinates x,y for each point:”);
for ( i=0 ; i<n ; i++)
scanf(%d%d”, &x[i] ,&y[i]);
printf(“Entar scalling factors: (sfx,sfy)”);
Scanf(“%f%f ”,&sfx,&sfy);
Initgraph(&gd,&gm,”C:\\TC\\BGI”);
Cleardevice();
Setcolor(CYAN);
draw();
scale();
setcolor(YELLOW);
draw();
getch();
}
void draw(){
for(i=0; i<n; i++)
line(x[i], y[i], x[(i+1)%n], y[(i+1)%n]);
}
Void scale()
{
for (i=0; i<n; i++)
{
x[i]= x[0] + (int) ((float) (x[i] - x[0]) * sfx);

y[i] = y[0] + (int) ((float) (y[i] - y[0]) * sfy);


}
OUTPUT
CONCLUSION

In conclusion, the provided C code employs Turbo C's graphics library to create a simple
shape or object using 2D SCALING. Through the utilization of graphics functions, the code
establishes a graphical environment, initializes key parameters, and enters a loop that
orchestrates the 2D SCALING. 2D graphics are widely used in animation and video
games, providing a realistic, but flat, view of movement on the screen. 3D graphics provide
realistic depth that allows the viewer to see into spaces, notice the movement of light and
shadows, and gain a fuller understanding of what's being shown. This code serves as an
illustrative example of basic graphical programming concepts, offering insights into the
practical application of graphics functions for output within the Turbo C environment.
Additionally, the reliance on keyboard input for program termination highlights a user-
interactive aspect in the control flow of the output.
REFERENCES

1.https://www.youtube.com/watch?v=jP19H02Z8oo

2.https://byjus.com/gate/transformation-in-computer-graphics/#:~:text=2D
%20Scaling%20in%20Computer%20Graphics%20involves%20resizing
%20objects%20or%20coordinate,the%20x%20and%20y%20directions.

You might also like