📄 map45rotate.java
字号:
// 程序:立体座标定位
// 范例文件:Map45Rotate.java
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Map45Rotate extends Applet
{
int AppletWidth, AppletHeight,floorW,floorH,key;
Image floor,OffScreen;
Graphics drawOffScreen;
MediaTracker MT;
public void init()
{
setBackground(Color.white);
AppletWidth = getSize().width;
AppletHeight = getSize().height;
MT = new MediaTracker(this);
floor = getImage(getDocumentBase(),"Images/floor.gif");
MT.addImage(floor,0);
try
{
showStatus("图像载入中(Loading Images)...");
MT.waitForAll();
}
catch(InterruptedException E){ }
OffScreen = createImage(AppletWidth,AppletHeight);
drawOffScreen = OffScreen.getGraphics();
floorW = floor.getWidth(this);
floorH = floor.getHeight(this);
}
public void paint(Graphics g)
{
int X,Y;
for(int i=1; i <= 15; i++)
for(int j=1; j <= 15; j++)
{
X = rotateX(j,i);
Y = rotateY(j,i);
drawOffScreen.drawImage(floor,X,Y,X+floorW,
Y+floorH,0,0,floorW,floorH,this);
}
g.drawImage(OffScreen,0,0,this);
}
private int rotateX(int j, int i)
{
int x;
x = (j-i)*floorW + 450;
x = (int) (x*Math.cos(60*Math.PI/180));
return x;
}
private int rotateY(int j, int i)
{
int x, y;
x = j*floorW + 150;
y = -i*floorH;
y = (int ) -(y*Math.cos(-15*Math.PI/180) +
x*Math.sin(60*Math.PI/180)*Math.sin(-15*Math.PI/180));
y = y - i * floorH/2;
return y ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -