// Fire applet by Anarchriz (c) 1998. All rights reserved. Contact me for more info. import java.awt.*; import java.applet.*; public class FireApplet extends AnimatedApplet { private int[] pixelMap1; private int[] pixelMap2; private int[] temp; private int[] palette=new int[0x200]; private int realWidth; private int realHeight; private int numberOfSources=25; private int widthSource=4; private int initHeat=0x100; private int blackDist=10; private boolean doubleSize=false; private boolean clipFire=true; private int heatWidth, position, convert; public void init(){ super.init(); String para1=getParameter("doubleSize"); String para2=getParameter("clipFire"); if (para1!=null) if (para1.equals("true")) doubleSize=true; if (para2!=null) if (para2.equals("false")) clipFire=false; if (doubleSize) { realWidth=width/2; realHeight=height/2; numberOfSources/=2; blackDist/=2; widthSource/=2; } else { realWidth=width; realHeight=height; } pixelMap1=new int[realWidth*(realHeight+blackDist)]; pixelMap2=new int[realWidth*(realHeight+blackDist)]; // Init pixel arrays to zero (black) for (int i=0; i=realWidth+1; i--){ //For each pixel from pixelMap1 is the average of its environment calculated... int average=(pixelMap1[i-realWidth-1]+pixelMap1[i-realWidth]+pixelMap1[i-realWidth+1]+ pixelMap1[i-1]+pixelMap1[i+1]+ pixelMap1[i+realWidth-1]+pixelMap1[i+realWidth]+pixelMap1[i+realWidth+1])>>3; //... and put one line higher in pixelMap2 pixelMap2[i-realWidth]=average; //Convert heat numbers to 'real' colors in the pixels array if (i=0xB0) pixels[i]=0xFFFFFF; else pixels[i]=palette[average]; } else { convert=(i-i%realWidth)*4+(i%realWidth)*2; if (average>=0xB0) { pixels[convert]=0xFFFFFF; pixels[convert+1]=0xFFFFFF; pixels[convert+width]=0xFFFFFF; pixels[convert+width+1]=0xFFFFFF; } else { pixels[convert]=palette[average]; pixels[convert+1]=palette[average]; pixels[convert+width]=palette[average]; pixels[convert+width+1]=palette[average]; } } } } pixelMap1=pixelMap2; pixelMap2=temp; for (int i=0; i