📄 ripple.java
字号:
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class Ripple {
public static short[] lut = null;
public Ripple() {
int amplitude = 1 << 10;
lut = new short[360];
int factor = ((360 * 10000 / 2) / 31415);
int a = amplitude * factor;
int c = 0;
int d;
for (int cnt = 0; cnt < 360; cnt++) {
d = c / factor;
lut[cnt] = (short) d;
a -= d;
c += (a / factor);
}
lut[180] = 0;
lut[270] = -1024;
}
public static short sin(int value) {
value = value % 360;
return lut[value];
}
public void paintImageFade(Graphics g, //画笔
int curStep, //帧数
int numSteps,//总帧数
int type, // 波纹类型
Image fadeImage, // 图片
int imageX, // 绘制坐标
int imageY, // 绘制坐标
int numWaves // 波纹数量
) {
if (curStep >= numSteps) {
g.drawImage(fadeImage, imageX, imageY, 0);
return;
}
int fadeImageWidth, fadeImageHeight;
if (type == 0) {
fadeImageWidth = fadeImage.getWidth();
fadeImageHeight = fadeImage.getHeight();
} else {
fadeImageWidth = fadeImage.getHeight();
fadeImageHeight = fadeImage.getWidth();
}
int halfFadeImageWidth = fadeImageWidth / 2;
int numSegments = fadeImageHeight;
int curWidth = fadeImageWidth * curStep / numSteps;
int amp = fadeImageWidth * (numSteps - curStep) / (numSteps * 4); // fadeImageWidth/4*(numSteps-curStep)/numSteps
int curOffset;
int curAngle = 360 * curStep / numSteps;
int angleStep = 360 * numWaves / numSegments;
for (int i = 0; i < numSegments; i++) {
curOffset = amp * sin(curAngle) >> 10;
if (type == 0) {
g.setClip(imageX + halfFadeImageWidth - curWidth / 2
+ curOffset, imageY + i, curWidth, 1);
g.drawImage(fadeImage, imageX + curOffset, imageY, 0);
} else {
g.setClip(imageX + i, imageY + halfFadeImageWidth - curWidth
/ 2 + curOffset, 1, curWidth);
g.drawImage(fadeImage, imageX, imageY + curOffset, 0);
}
curAngle += angleStep;
}
}
}
// util.paintImageFade(SySDB.ShowG, SySDB.Zheng - 11, 15, 0, logoImage[0],
// (SysW - logoImage[0].getWidth()) / 2,
// (SysH - logoImage[0].getHeight()) / 2, 5);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -