package ca; import java.awt.*; import java.awt.image.*; import java.util.*; public class Rug extends CAs { private protected static final boolean DEBUG = false; public Rug(){} public void setTarget(Component target){ STATE=16; cols = new int[STATE]; int a = 0xff000000; int r,g,b; for(int i = 0; i < cols.length; i++){ r = ((int)(Math.sin(i*4)*255) << 16) & 0xff0000; g = ((int)(Math.cos(i*0.3+2.5)*255) << 8) & 0xff00; b = (int)(Math.cos(i*0.1)*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){ 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]; // test = count / 8 + 1 int test = (int)( ((count >> 3) + 1) & 15); //if( test > STATE - 1 ){ // test = test - STATE; //}else if (test < 0){ // test = 0; //} cells2[x2][y2] = (short)(test); } }