package ca; import java.awt.*; import java.awt.image.*; import java.util.*; public class Faders extends CAs { private protected static final boolean DEBUG = false; short tableA[][] = {{0,0,1,0,0,0,0,0,0}, {2,2,1,2,2,2,2,2,2}}; short table[][]; public Faders(){ table = new short[65][9]; for(byte i = 0;i<2;i++){ for(byte j = 0;j<9;j++){ table[i][j] = tableA[i][j]; } } for(byte i = 2;i<64;i+=2){ for(byte j = 0;j<9;j++){ table[i][j] = (short)(i+2); } } for(byte j = 0;j<9;j++){ table[64][j] = (short)0; } } public void Randmize(short array[][]){ for(int i = 0;i 2 ){ temp = 2 *(temp-1);} if (temp < 0){ temp = 0; }else if (temp > 64){ temp = 1; } //*/ array[i][j] = (short)temp; } } } public void setTarget(Component target){ STATE=65; cols = new int[STATE]; int a = 0xff000000; int r,g,b; for(int i = 0; i < STATE; i ++){ r = ((int)(Math.sin(i*3)*255) << 16) & 0xff0000; g = ((int)(Math.cos(i*1.8+2.5)*255) << 8) & 0xff00; b = (int)(Math.cos(i*0.6)*255) & 0xff; cols[i] = (a|r|g|b); } cols[0] = 0xff000000; super.setTarget(target); } public void check(int x1,int x2,int x3,int y1,int y2,int y3){ if(DEBUG){ if(!(cells[x2][y2]>=0 && cells[x2][y2]<=STATE-1)) System.out.println("P = " + cells[x2][y2]); } int msk = 1; int count = (cells[x1][y1] & msk) + (cells[x1][y2] & msk) + (cells[x1][y3] & msk) + (cells[x2][y1] & msk) + (cells[x2][y3] & msk) + (cells[x3][y1] & msk) + (cells[x3][y2] & msk) + (cells[x3][y3] & msk); if (DEBUG){ if(!(count>=0 && count<=8)) System.out.println("count = " + count); } cells2[x2][y2] = table[cells[x2][y2]][count]; } }