Question: Smart Computers Graphics Questions: Write Java code to display a rectangle box and apply the following transformation Scaling. Please note that if any data is
Smart Computers Graphics


Questions: Write Java code to display a rectangle box and apply the following transformation Scaling. Please note that if any data is required, such as scaling factor, please assume some values and specify them in the program with the comments. 23C Cloudy DUL Enig F4 FS F10 F11 612 Entt $ % & p3 3 E 4 6 B Ri ZUG P import java.applet.Applet; import java.awt.Graphics; public class Draw extends Applet { int Ox1 = 50; int Oy1 = 50; int Ox2 = 250; int Oy2 = 50; int Ox3 = 250; int Oy3 = 150; int Ox4 = 50; int Oy4 = 150; int Tx =100; int Ty=100; int nx1,ny1,nx2,ny2, nx3,ny3,nx4, ny4; public void paint(Graphics e) { g.drawLine(Ox1,0y1,0x2,0y2); g.drawLine(Ox2,0y2,0x3,0y3); g.drawLine(Ox3,Oy3,0x4,0y4); g.drawLine(Ox4,0y4,0x1,0y1); nx1= Ox1+Tx; ny1= Oy1+TY; nx2= Ox2+Tx; ny2= Oy2+Ty; nx3= Ox3+Tx; ny3= Oy3+Ty; nx4=Ox4+Tx; ny4= Oy4+TY; g.drawLine(nx1,nyi,nx2,ny2); g.drawLine(nx2,ny2,nx3,ny3); g.drawLine(nx3,ny3,nx4, ny4); g.drawLine(nx4, ny4,nx1,ny1); } W
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
