String themeList[] = {"themeOne", "themeRandom", "themeH1", "themeH5", "themeV1", "themeV5"}; abstract class Itheme { Itheme(color _col, int i) { running = false; col = _col; ix = i; name = ""; speed = 1; } abstract public boolean start(int _speed); abstract public boolean update(boolean paused); public boolean hasfinished() { return running; } public String getname() { return name; } public void setspeed(int _speed) { speed = float(_speed % 3)/2.0 + 1.0; } protected boolean running; protected String name; protected color col; protected int ix; protected float speed; } class themeOne extends Itheme { int dev; themeOne(color _col, int i) { super(_col, i); name = "themeOne"; dev = int(random(4)); } public boolean start(int _speed) { setspeed(_speed); running = true; return true; } public boolean update(boolean paused) { if(paused) return true; for(int i = 0; i < num; ++i) { if(i%(9+second()%10+dev)/speed == 0 && !paused) windows[i].glow(col, .33, 2.0/speed, 0.5/speed, ix); } return true; } } class themeRandom extends Itheme { float nps, npf, rnpf; themeRandom(color _col, int i, float npersec) { super(_col, i); name = "themeRandom"; nps = npersec; } public boolean start(int _speed) { setspeed(_speed); running = true; return true; } public boolean update(boolean paused) { if(paused) return true; npf = nps / frameRate * speed; rnpf = 1.0 / npf; if(npf < 1.0 && int(random(rnpf)) == 1) { windows[int(random(num))].glow(col, .33, (2.0+random(4.0))/speed, 1.0/speed, ix); } else { for(int i = 0; i < npf; ++i) { windows[int(random(num))].glow(col, .33, (2.0+random(4.0))/speed, 1.0/speed, ix); } } return true; } } class themeVhBase extends Itheme { boolean vertical; int nbright; int n, len, nupd, updr; float dir; int pos[]; themeVhBase(color _col, int i, boolean _vertical, int _nbright) { super(_col, i); name = "themeVhBase"; vertical = _vertical; nbright = _nbright; n = 1; dir = 1.0; } public boolean start(int _speed) { setspeed(_speed); if(vertical) { len = h; n = h / (8 + 3*nbright); } else { len = 2*(w+l); n = len / (12 + 3*nbright); } if(n <= 0) n = 1; if(int(random(2)) == 1) dir = 1.0; else dir = -1.0; pos = new int[n]; for(int i = 0; i < n; ++i) { int dst = len / n; pos[i] = i*dst + int(random(dst/2)); } updr = int(frameRate / 2.0); nupd = frameCount + int(updr / speed); running = true; return true; } public boolean update(boolean paused) { if(paused) return true; if(nupd <= frameCount) { for(int i = 0; i < n; ++i) { boolean isnew = false; if(dir > 0.0) { ++pos[i]; isnew = true; if(pos[i] >= len) pos[i] = 0; } else { --pos[i]; isnew = true; if(pos[i] < 0) pos[i] = len - 1; } if(isnew) { float fifofa = float(nbright)/1.0; if(fifofa < 1.0) fifofa = 1.0; if(vertical) { int nw = 2*(w+l); int ph = nw * pos[i]; for(int j = 0; j < nw; ++j) { windows[j+ph].glow(col, .33, nbright*1.5/speed, .5/speed*fifofa, ix); } } else { int nw = 2*(w+l); for(int j = 0; j < h; ++j) { windows[pos[i]+j*nw].glow(col, .33, nbright*1.5/speed, .5/speed*fifofa, ix); } } updr = int(frameRate / 2.0); nupd = frameCount + int(updr / speed); } } } return true; } } class themeH1 extends themeVhBase { themeH1(color _col, int i) { super(_col, i, false, 1); name = "themeH1"; } } class themeH5 extends themeVhBase { themeH5(color _col, int i) { super(_col, i, false, 5); name = "themeH5"; } } class themeV1 extends themeVhBase { themeV1(color _col, int i) { super(_col, i, true, 1); name = "themeV1"; } } class themeV5 extends themeVhBase { themeV5(color _col, int i) { super(_col, i, true, 5); name = "themeV5"; } }