Total members 11893 |It is currently Sun Nov 03, 2024 3:34 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





This a simple java code for scaling rectangle 2D.Using Scaling varrible 2x.

java code
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;

/**
*
* @author mohamed

*/
public class Scaling extends JFrame{

private int width=400;
private int height=400;
private int x1=50;
private int y1=50;
private int scale=2;

public Scaling() {
setTitle("Scaling");
setSize(width,height);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
public void paint(Graphics g) {
g.fillRect(0,0,400,400);
g.setColor(Color.YELLOW);
g.drawRect(200,200,x1,y1);
g.setColor(Color.GREEN);
x1*=scale;
y1*=scale;
g.drawRect(200,200,x1,y1);

}
public static void main(String[] args) {
// TODO code application logic here
new Scaling();
}

}




_________________
Recommend my post if you found it helpful.


Author:
Newbie
User avatar Posts: 15
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Scaling 2D
 compute maximum and minimum values, also scaling factor.     -  



Topic Tags

Java Graphics
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com