/* * iterated interleavers */ import java.awt.*; public class IteratedLinear extends java.applet.Applet { int a = 1; int b = 1; int c = 1; int d = 2; public void init() { } public void paint(Graphics g) { int[] xy = new int[2]; int[] zw = new int[2]; for (int t = 0; t < 6; t++) { // do t iterations of map g.setColor(Color.red); for (int i=0; i<50; i++) { // upper left 1/5 x 1/5 for (int j=0; j<50; j++) { xy[0] = i; xy[1] = j; zw = f(xy, t); g.fillRect(t*150+zw[0],zw[1],1,1); } } g.setColor(Color.blue); for (int i=50; i<100; i++) { for (int j=0; j<50; j++) { xy[0] = i; xy[1] = j; zw = f(xy, t); g.fillRect(t*150+zw[0],zw[1],1,1); } } g.setColor(Color.green); for (int i=0; i<50; i++) { for (int j=50; j<100; j++) { xy[0] = i; xy[1] = j; zw = f(xy, t); g.fillRect(t*150+zw[0],zw[1],1,1); } } g.setColor(Color.black); g.drawRect(150*t,0,150,150); } } int[] f( int[] xy ) { // 149 is prime... int[] out = new int[2]; out[0] = (a*xy[0]+b*xy[1]) % 149; out[1] = (c*xy[0]+d*xy[1]) % 149; return out; } int[] f( int[] xy, int t ) { int[] out = new int[2]; out[0] = xy[0]; out[1] = xy[1]; if (t>0) { for (int i=0; i