class ForestFire{ int w, h; float[][] heightMap; float[][] flammability; float[][] fuel; float[][] fire, fireChange; float step = 0.95; float maxHeight = 100; float maxFuel = 256; float speed = 2.0; //------------ ForestFire(int w, int h){ this.w = w; this.h = h; // initialize arrays heightMap = new float[w][h]; flammability = new float[w][h]; fuel = new float[w][h]; fire = new float[w][h]; fireChange = new float[w][h]; float offset = random(0,47.11); float s = 0.02; for(int x=0;x 0 ){ // fire cell for(int i=0; i 0 ){ fire[x][y] += speed*4*(fuel[x][y]/maxFuel - 0.2); fuel[x][y] -= speed*fire[x][y]/256; } } } //------------ float posterize(float x){ return ((int)(8*x))/(float)8; } //------------ color getColor(int x, int y){ colorMode(RGB,255); if( fire[x][y]>0 ) return (random(1)<0.5 ? color(255,192,0) : color(255,64,0) ); colorMode(HSB,1); float h = 1-flammability[x][y]; float s = fuel[x][y]/255; float b = (0.25+0.75*fuel[x][y]/maxFuel) * (heightMap[x][y]/(float)maxHeight); return color( posterize(h), s, posterize(b) ); //return color( 0, 255-255*heightMap[x][y]/(float)maxHeight, fuel[x][y] ); } //------------ void visualize(){ loadPixels(); for(int x=0; x