知识大全 一个用java演示的产生图像烟花的算法
Posted 结束
篇首语:一知半解的人,多不谦虚;见多识广有本领的人,一定谦虚。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 一个用java演示的产生图像烟花的算法相关的知识,希望对你有一定的参考价值。
以下是一个用java演示的产生图像烟花的算法 可以用来研究以下相关的东西 希望对有兴趣的朋友有用 import java applet AudioClip; import java awt *; import java awt image MemoryImageSource; import java util Random; public class jhanabi extends Applet implements Runnable // 类成员变量定义域开始 private int m_nAppX; private int m_nAppY; private int m_centerX; private int m_centerY; private int m_mouseX; private int m_mouseY; private int m_sleepTime; private boolean isError; private boolean m_isPaintFinished; boolean isRunning; boolean isInitialized; Thread runner; int pix []; MemoryImageSource offImage; Image dbImg; int pixls; int pixls ; Random rand; int bits; double bit_px[]; double bit_py[]; double bit_vx[]; double bit_vy[]; int bit_sx[]; int bit_sy[]; int bit_l[]; int bit_f[]; int bit_p[]; int bit_c[]; int bit_max; int bit_sound; int ru; int rv; AudioClip sound ; AudioClip sound ; // 类成员变量定义域结束 < 初始化过程祥见构造方法 >
public jhanabi// 构造方法 (如有必要 请手工调整该方法) m_mouseX = ; m_mouseY = ; m_sleepTime = ; isError = false; isInitialized = false; rand = new Random; bits = ; bit_px = new double[bits]; bit_py = new double[bits]; bit_vx = new double[bits]; bit_vy = new double[bits]; bit_sx = new int[bits]; bit_sy = new int[bits]; bit_l = new int[bits]; bit_f = new int[bits]; bit_p = new int[bits]; bit_c = new int[bits]; ru = ; rv = ; // jhanabi 结束 //构造方法结束 public void init String s = getParameter( para_bits ); if(s != null) bits = Integer parseInt(s); s = getParameter( para_max ); if(s != null) bit_max = Integer parseInt(s); s = getParameter( para_blendx ); if(s != null) ru = Integer parseInt(s); s = getParameter( para_blendy ); if(s != null) rv = Integer parseInt(s); s = getParameter( para_sound ); if(s != null) bit_sound = Integer parseInt(s); m_nAppX = size width; m_nAppY = size height; m_centerX = m_nAppX / ; m_centerY = m_nAppY / ; m_mouseX = m_centerX; m_mouseY = m_centerY; resize(m_nAppX m_nAppY); pixls = m_nAppX * m_nAppY; pixls = pixls m_nAppX * ; pix = new int[pixls]; offImage = new MemoryImageSource(m_nAppX m_nAppY pix m_nAppX); offImage setAnimated(true); dbImg = createImage(offImage); for(int i = ; i < pixls; i++) pix [i] = xff ; sound = getAudioClip(getDocumentBase firework au ); sound = getAudioClip(getDocumentBase syu au ); for(int j = ; j < bits; j++) bit_f[j] = ; isInitialized = true; start; //init 结束 public void run while(!isInitialized) try Thread sleep( L); catch(InterruptedException interruptedexception) do for(int j = ; j < pixls ; j++) int k = pix [j]; int l = pix [j + ]; int i = pix [j + m_nAppX]; int j = pix [j + m_nAppX + ]; int i = (k & xff ) > > ; int k = ((((l & xff ) > > ) i) * ru > > ) + i; i = (k & xff ) > > ; int l = ((((l & xff ) > > ) i) * ru > > ) + i; i = k & xff; int i = (((l & xff) i) * ru > > ) + i; i = (i & xff ) > > ; int j = ((((j & xff ) > > ) i) * ru > > ) + i; i = (i & xff ) > > ; int k = ((((j & xff ) > > ) i) * ru > > ) + i; i = i & xff; int l = (((j & xff) i) * ru > > ) + i; int i = ((j k ) * rv > > ) + k ; int j = ((k l ) * rv > > ) + l ; int k = ((l i ) * rv > > ) + i ; pix [j] = i < < | j < < | k | xff ; //for 结束 rend; offImage newPixels( m_nAppX m_nAppY); try Thread sleep(m_sleepTime); catch(InterruptedException interruptedexception ) // do 结束 while(true); //run 结束 public void update(Graphics g) paint(g); public void paint(Graphics g) g drawImage(dbImg this); public void start if(isError) return; isRunning = true; if(runner == null) runner = new Thread(this); runner start; public void stop if(runner != null) runner stop; runner = null; public boolean mouseMove(Event event int i int j) m_mouseX = i; m_mouseY = j; return true; public boolean mouseDown(Event event int i int j) m_mouseX = i; m_mouseY = j; int k = (int)(rand nextDouble * D); int l = (int)(rand nextDouble * D); int i = (int)(rand nextDouble * D); int j = k < < | l < < | i | xff ; int k = ; for(int l = ; l < bits; l ++) if(bit_f[l ] != ) continue; bit_px[l ] = m_mouseX; bit_py[l ] = m_mouseY; double d = rand nextDouble * D; double d = rand nextDouble; bit_vx[l ] = Math sin(d) * d ; bit_vy[l ] = s(d) * d ; bit_l[l ] = (int)(rand nextDouble * D) + ; bit_p[l ] = (int)(rand nextDouble * D); bit_c[l ] = j ; bit_sx[l ] = m_mouseX; bit_sy[l ] = m_nAppY ; bit_f[l ] = ; if(++k == bit_max) break; if(bit_sound > ) sound play; return true; //mouseDown 结束 public boolean mouseExit(Event event int i int j) m_mouseX = i; m_mouseY = j; return true; void rend boolean flag = false; boolean flag = false; boolean flag = false; for(int k = ; k < bits; k++) switch(bit_f[k]) default: break; case : // \\ bit_vy[k] += rand nextDouble / D; bit_px[k] += bit_vx[k]; bit_py[k] += bit_vy[k]; bit_l[k] ; if(bit_l[k] == || bit_px[k] < D || bit_py[k] < D || bit_px[k] > (double)m_nAppX || bit_py[k] > (double)(m_nAppY )) bit_c[k] = xff ; bit_f[k] = ; else if(bit_p[k] == ) if((int)(rand nextDouble * D) == ) bit_set((int)bit_px[k] (int)bit_py[k] ); else bit_set((int)bit_px[k] (int)bit_py[k] bit_c[k]); break; case : // \\ bit_sy[k] = ; if((double)bit_sy[k] <= bit_py[k]) bit_f[k] = ; flag = true; if((int)(rand nextDouble * D) == ) int i = (int)(rand nextDouble * D); int j = (int)(rand nextDouble * D); bit_set(bit_sx[k] + i bit_sy[k] + j ); break; //switch 结束 if(flag && bit_sound > ) sound play; // rend 结束 void bit_set(int i int j int k) int l = i + j * m_nAppX; pix [l] = k; cha138/Article/program/Java/hx/201311/26065相关参考
摄影者在拍摄烟花时,一定要安装三脚架,三脚架能够帮助你防止出现图像抖动现象。在拍摄烟花之前,要先构思好摄影构图并确定拍照的位置,然后用三脚架把相机固定好。在拍摄烟花时,最好采用手动模式,然后对焦到无穷
Java扫雷算法 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧! 建立一个雷区可以用一个一个的JB
用JAI扩展Java的图像处理能力 以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!lishixinz
知识大全 数据结构 9.10 二叉查找树的删除算法演示(二)
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 T在函数DeleteBST中是一个递归调用的引用型参数第一次调用时的参数是指
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 模式串T=abcac和主串S=ababcabcabcacabca在pos=的
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 voidCreateBiTree(BiTree&T) //在先
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 voidMsort(RcdTypeSR[]RcdTypeTR[]intsin
在JAVA程序设计中事件的处理是非常重要的尤其是在需要自定义事件和设计JavaBean时对事件的处理过程有一个完整的认识对于编程是很有帮助的 下面用一个演示性的例子来说明事件及其处理过程
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 首先将移至暂存空间R[]将和进行比较后得到的大者与进行比较由于>则应将
希赛教育计算机专业考研专业课辅导招生 希赛教育计算机专业考研专业课辅导视频 希赛教育计算机考研专业课在线测试系统 模式串T=abcac和主串S=ababcabcabcacabca在pos=的