-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScaling.cpp
40 lines (30 loc) · 853 Bytes
/
Scaling.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <graphics.h>
void scaleRectangle(int x[], int y[], int scaleX, int scaleY) {
// Drawing original rectangle
setcolor(RED);
rectangle(x[0], y[0], x[1], y[1]);
// Scaling the rectangle
x[0] *= scaleX;
x[1] *= scaleX;
y[0] *= scaleY;
y[1] *= scaleY;
// Drawing scaled rectangle
setcolor(GREEN);
rectangle(x[0], y[0], x[1], y[1]);
}
int main() {
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
int x[2] = {100, 200}; // Coordinates of top-left and bottom-right points of the rectangle
int y[2] = {100, 200};
int scaleX = 2; // Scaling factors
int scaleY = 2;
// Draw original rectangle
rectangle(x[0], y[0], x[1], y[1]);
// Scale and draw the rectangle
scaleRectangle(x, y, scaleX, scaleY);
getch();
closegraph();
return 0;
}