Hello,
here is the class file for rotation, as the image rotates it moves towards left, should stay stable or rotate around the mentioned co ordinates
package draw;
import java.awt.*;
import java.awt.image.BufferedImage;
public class Rotation extends java.applet.Applet {
final static int BALL_RADIUS = 45;
BufferedImage ball = null;
public void init()
{
ball = new BufferedImage(BALL_RADIUS, BALL_RADIUS, BufferedImage.TYPE_INT_RGB);
Graphics ballG = ball.getGraphics();
ballG.setColor(Color.white);
for(int i=-20;i<=0;i++)
{
ballG.drawOval(i, i, BALL_RADIUS + ((-i)*2), BALL_RADIUS + ((-i)*2));
}
}
public void paint(Graphics g)
{
float angle = 0;
double speed = 0.1;
int x = 140;
int y = 140;
for(int c=0;c<1600;c++)
{
float radius = 4;
x = (int) (x + Math.cos(angle) * radius);
y = (int) (y + Math.sin(angle) * radius);
angle += speed;
g.fillRect(42, 45, getBounds().width, getBounds().height);
g.setColor(Color.white);
g.drawImage(ball, x, y, this);
delay(25);
}
System.out.println("paint() done");
}
private void delay(int millis)
{
try{Thread.sleep(millis);}catch(Exception ignored){}
}
}