public class TestMISApplet extends MISApplet { public void initFrame(double time) { centerY = 256* (1+Math.cos(time)); centerX= ((50*time)%256); factorC=50*(1+Math.cos(2.5*time)); } public void setPixel(int x, int y, int rgb[]) { double X = x-W/2; double Y = y-H/2; rgb[0] = rgb[1] = rgb[2] = (int)(255 * line(X, centerX) * line(Y,centerY)); double circ = diskVar(X*X+Y*Y, W/8,28); double len; if (Y!=0){ len = Math.atan(X/Y)/(2*Math.PI); } else{ if (X>=0) len = 1/4; else len = -1/4; } if (Y>0) len += 1/2; len+=1/4; len = Math.tan(10*2*Math.PI*len); double circ2 = diskVar(X*X+Y*Y, W/8,30); double circ3 = diskVar2(X*X+Y*Y, W/5,1+len*factorC); //double circ = circle(X*X+Y*Y, W/8); rgb[0] = (int)(127 * line(x, centerX) ); rgb[2] = (int)(127 * line(y, centerY) ); rgb[1] = (int)(127 * line(x, centerX)*line(y,centerY )); for (int toto=0;toto<2;toto++){ rgb[toto]+= (int)(100*circ); rgb[toto]+= (int)(50*circ3); } } //--------------------------------------------------------- private double disk(double rr, double R) { double dd = rr - R*R; return dd >= 2*R ? 0 : dd <= -2*R ? 1 : (2*R - dd) / (4*R); } private double diskVar(double rr, double R, double marg) { double dd = rr - R*R; return dd >= marg*R ? 0 : dd <= -marg*R ? 1 : (marg*R - dd) / (2*marg*R); } private double diskVar2(double rr, double R, double marg) { double dd = rr - R*R; return dd >= marg*R ? 0 : dd <= -2*R ? 0 : ((marg+2)/2*R - dd) / ((2+marg)*R); } private double circle(double rr, double R) { double dd=rr-R*R; return dd>=2*R? 0 : dd <= -2*R? 0 : 1; } private double line(double x1, double x0) { return x1>=1.5*x0 ? 0: x1<=0.5*x0 ? 1: 1.5-x1/x0; } private double centerX=0, centerY=0, factorC=1; }