package ca; import java.awt.*; import java.awt.image.*; import java.util.*; public class Melt extends CAs { private protected static final boolean DEBUG = false; public Melt(){} public void setTarget(Component target){ STATE = 256; cols = new int[STATE]; int a = 0xff000000; int r,g,b; for(int i = 0; i < cols.length; i++){ r = (((i % 32)*8) << 16) & 0xff0000; g = (((i % 64)*4) << 8) & 0xff00; b = (255 - i) & 0xff; cols[i] = (a|r|g|b); //System.out.println("R = " + ((cols[i]&0xff0000)>>16) + " G = " + ((cols[i]&0xff00)>>8) + " B = " + (cols[i]&0xff)); } super.setTarget(target); } public void check(int x1,int x2,int x3,int y1,int y2,int y3){ int count = cells[x1][y1] + cells[x1][y2] + cells[x1][y3] + cells[x2][y1] + cells[x2][y3] + cells[x3][y1] + cells[x3][y2] + cells[x3][y3]; int test = (int)(count>>3); if(test > STATE-1){test = STATE - 1; }else if ( test < 0 ){test = 0;} cells2[x2][y2] = (short)test; } }