JAVA源代码!可以显示水波效果!
2005-03-30 23:10
357 查看
水波效果程序:
import java.awt.*;
import java.applet.Applet;
public class Splash extends Applet implements Runnable{
int XMAX=112;
float[] m_Height=new float[XMAX];
float[] m_G=new float[XMAX];
float b=1.01f;
float fWeight=3;
private Thread m_NAMI2D=null;
public boolean mouseDown(Event event,int i,int j){
m_Height[i/4-1]+=j/2;
m_Height[i/4]+=j;
m_Height[i/4+1]+=j/2;
return false;
}
public void paint(Graphics g){
g.setColor(Color.blue);
float f1=3F*fWeight;
float f2=f1-2.0F;
m_Height[0]=m_Height[1];
m_Height[XMAX-1]=m_Height[XMAX-2];
float f=m_Height[0];
for(int i=1;i<XMAX-1;i++){
float f3=((f+f2*m_Height[i]+m_Height[i+1])/f1+m_G[i])/b;
f=m_Height[i];
m_G[i]=f3-f;
m_Height[i]=f3;
g.clearRect((i-1)*4,(int)f3-30,4,60);
g.fillRect((i-1)*4,(int)f3+30,4,60);
}
}
public void run(){
do
try{
repaint();
Thread.sleep(50L);
}
catch(InterruptedException _ex){
stop();
}
while(true);
}
public void start(){
if(m_NAMI2D==null){
m_NAMI2D=new Thread(this);
m_NAMI2D.start();
}
}
public void stop(){
if(m_NAMI2D!=null){
m_NAMI2D.stop();
m_NAMI2D=null;
}
}
public void update(Graphics g){
paint(g);
}
}
import java.awt.*;
import java.applet.Applet;
public class Splash extends Applet implements Runnable{
int XMAX=112;
float[] m_Height=new float[XMAX];
float[] m_G=new float[XMAX];
float b=1.01f;
float fWeight=3;
private Thread m_NAMI2D=null;
public boolean mouseDown(Event event,int i,int j){
m_Height[i/4-1]+=j/2;
m_Height[i/4]+=j;
m_Height[i/4+1]+=j/2;
return false;
}
public void paint(Graphics g){
g.setColor(Color.blue);
float f1=3F*fWeight;
float f2=f1-2.0F;
m_Height[0]=m_Height[1];
m_Height[XMAX-1]=m_Height[XMAX-2];
float f=m_Height[0];
for(int i=1;i<XMAX-1;i++){
float f3=((f+f2*m_Height[i]+m_Height[i+1])/f1+m_G[i])/b;
f=m_Height[i];
m_G[i]=f3-f;
m_Height[i]=f3;
g.clearRect((i-1)*4,(int)f3-30,4,60);
g.fillRect((i-1)*4,(int)f3+30,4,60);
}
}
public void run(){
do
try{
repaint();
Thread.sleep(50L);
}
catch(InterruptedException _ex){
stop();
}
while(true);
}
public void start(){
if(m_NAMI2D==null){
m_NAMI2D=new Thread(this);
m_NAMI2D.start();
}
}
public void stop(){
if(m_NAMI2D!=null){
m_NAMI2D.stop();
m_NAMI2D=null;
}
}
public void update(Graphics g){
paint(g);
}
}
相关文章推荐
- combogrid使用javascript及java做出既可以全部查询也可以模糊查询并显示的效果
- excel表格设置之冻结窗口(效果:让整个表格分成几部分,可以让下面的内容滚动显示)
- 一种简单的方法在程序中实现透明效果(JAVA)(源代码)
- java整理软件--- Java OCR 图像智能字符识别技术,可识别中文,但是验证码不可以识别...已测识别中文效果很好
- 又一个jquery轮播效果,焦点图,带数字显示序号,这个可以添加对应标题在图片上,支持主流浏览器
- 以 “月” 为单位的可以翻页的效果 显示为 2016年01月
- Android Studio第二十期 - 识别Recorder声纹显示水波泡泡效果
- 我孤陋寡闻了,原来bs里也可以实现像cs里的groupbox类型的显示效果
- java 分页显示效果
- 字符串处理是许多程序中非常重要的一部分,它们可以用于文本显示,数据表示,查找键和很多目的.在Unix下,用户可以使用正则表达式的强健功能实现这些 目的,从Java1.4起,Java核心API就引入了java.util.regex程序包,它是一种有价值的基础
- 这个用C++实现的效果可以用C#或JAVA实现吗
- java 实现显示屏上字符串滚动显示的效果
- 为什么我的Eclipse在单步调试Tomcat项目时没有Java源代码同步显示?
- 要在当前页面刷新,触发点击事件才可以显示效果的问题
- Jquery实现的tab效果可以指定默认显示第几页
- div不显示滚动条但实现鼠标移上去可以上下滚动的效果
- 如何不必发布就可以在IE上显示WEB修改效果
- cocos2d-x 显示触摸操作(显示水波点击效果,用于视频演示)
- 优化Java动画编程中的显示效果
- 关于Firefox中的Flash不可以显示透明效果的问题