Computer graphics program in Python graphics.py and c++ graphics.
Python
from graphics import *
win = GraphWin("Scale Square", 600, 600)
print("Corner 1")
x1=int(input("Enter x"))
y1=int(input("Enter y"))
c1=Point(x1, y1)
print("Corner 2")
x2=int(input("Enter x"))
y2=int(input("Enter y"))
c2 = Point(x2, y2)
s = Rectangle(c1, c2)
s.draw(win)
sx=float(input("Scaling Factor sx"))
sy=float(input("Scaling Factor sy"))
x1*=sx
x2*=sx
y1*=sy
y2*=sy
c1=Point(x1, y1)
c2 = Point(x2, y2)
ss=Rectangle(c1, c2)
ss.draw(win)
win.getMouse()
win.close()
C++
#include<bits/stdc++.h>
#include<graphics.h>
#include<conio.h>
using namespace std;
int main(){
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
int mx = getwindowwidth();
int my = getwindowheight();
int left = mx / 2 - 50;
int top = my / 2 - 50;
int right = mx / 2 + 50;
int bottom = my / 2 + 50;
rectangle(left, top, right, bottom);
cout <<"Enter the scaling factors Sx and Sy ";
float sx, sy;
cin >> sx >> sy;
left = left * sx;
right = right * sx;
top = top * sy;
bottom = bottom * sy;
cleardevice();
rectangle(left, top, right, bottom);
getch();
closegraph();
return 0;
}
Before Scaling
After scaling