Class java untuk rotasi Gambar
import greenfoot.*;
import java.awt.Color;
public class TransformImage
{
public GreenfootImage rotate(GreenfootImage image,int degree)
{
double angle=1.0*degree*Math.PI/180;
GreenfootImage imageo=new GreenfootImage(image.getWidth(),image.getHeight());
for(int i=0;i<image.getWidth();i++){
for(int j=0;j<image.getHeight();j++){
Color warna=image.getColorAt(i,j);
int ia=(int)(1.0*i-0.5*image.getWidth());
int ja=(int)(1.0*j-0.5*image.getHeight());
int io=(int)(ia*Math.cos(angle)-ja*Math.sin(angle));
int jo=(int)(ia*Math.sin(angle)+ja*Math.cos(angle));
io=(int)(1.0*io+0.5*image.getWidth());
jo=(int)(1.0*jo+0.5*image.getHeight());
if(io>=0 && jo>=0 && io<image.getWidth() && jo<image.getHeight()){
imageo.setColorAt(io,jo,warna);
}
}
}
return imageo;
}
}