The rest of the code is not that important I think and also very long and quite messy, but still:
final color bgc = color(0);
final color mc = color(255);
final float scs = 18;
final float bcs = 23;
final float lg = 20;
final float hgr = 56;
final float blt = 8;
final float slt = 6;
LineWorker lw;
void setup(){
size(400, 400);
ellipseMode(CENTER);
lw = new LineWorker();
}
void draw(){
background(bgc);
lw.connectLines();
lw.drawAllLines();
filter(BLUR, 6);
lw.drawAllLines();
}
class LineWorker {
ArrayList<Line> Lines;
int mCounter;
byte mFlags = 0;
LineWorker() {
Lines = new ArrayList<Line>();
}
void drawAllLines() {
for (Line l : Lines) {
PVector s, e;
s = Coor2XY((int)l.s.x, (int)l.s.y);
e = Coor2XY((int)l.e.x, (int)l.e.y);
noStroke();
fill(mc);
ellipse(s.x, s.y, l.s.x==2?bcs:scs, l.s.x==2?bcs:scs);
ellipse(e.x, e.y, l.e.x==2?bcs:scs, l.e.x==2?bcs:scs);
stroke(mc);
strokeCap(ROUND);
if ((l.s.x == 1 && l.e.x == 2)||(l.s.x == 2 && l.e.x == 1)||(l.s.x == 2 && l.e.x == 3)||(l.s.x == 3 && l.e.x == 2)) {
strokeWeight(slt);
PVector sub = new PVector(s.x, s.y).sub(e);
PVector t = sub.mult(lg/sub.mag());
e = e.add(t);
s = s.add(t.mult(-1));
line(s.x, s.y, e.x, e.y);
} else if (l.s.x == 2 && l.e.x == 2) {
strokeWeight(blt);
line(s.x, s.y, e.x, e.y);
} else {
strokeWeight(slt);
line(s.x, s.y, e.x, e.y);
}
}
}
void connectLines() {
Lines.clear();
int h = hour() % 12;
int m = minute();
boolean pm = (hour() > 12)? true : false;
mCounter = m % 5;
int i = (h-1<0)? 11 : h-1, j = (int(m/5)-1<0)? 11 : int(m/5)-1;
int hAt;
if (i%2 == 0) {
Lines.add(new Line(2, i, 3, (i/2)*3));
hAt = (i/2)*3;
} else {
if (PRN() % 2 == 0) {
Lines.add(new Line(2, i, 3, (i/2)*3 + 1));
hAt = (i/2)*3 + 1;
} else {
Lines.add(new Line(2, i, 3, (i/2)*3 + 2));
hAt = (i/2)*3 + 2;
}
}
mFlags = 0x7F;
if (j%2 == 0) {
Lines.add(new Line(2, j, 1, int(j/2)));
int t = (int(j/2) % 6 + 1);
startNest(-1, t);
} else {
if (PRN() % 2 == 0) {
Lines.add(new Line(2, j, 1, int(j/2)));
int t = (int(j/2) % 6 + 1);
startNest(-1, t);
} else {
Lines.add(new Line(2, j, 1, int(j/2)+1));
int t = (int(j/2 + 1) % 6 + 1);
startNest(-1, t);
}
}
if (pm) {
if (random(8) % 2 == 0) {
Lines.add(new Line(3, hAt, 3, (hAt+1 > 17)? 0 : hAt + 1));
} else {
Lines.add(new Line(3, hAt, 3, (hAt-1 < 0)? 0 : hAt - 1));
}
}
if (i > j) {
int t = i;
i = j;
j = t;
}
for (int t = i; t != j; ) {
if (abs(i-j) == 6 && PRN()%2 == 0) {
Lines.add(new Line(2, t, 2, t+1));
t++;
} else if (abs(i-j) > 6) {
Lines.add(new Line(2, t, 2, t-1));
t--;
} else {
Lines.add(new Line(2, t, 2, t+1));
t++;
}
t = t<0? 11 : t%12;
}
}
void startNest(int _f, int _n) {
if (mCounter == 0) return;
byte near;
if (_n == 0) {
near = 0x7D;
} else if (_n != 1 && _n != 6) {
near = byte(0x05 << (_n-1));
} else {
near = byte(0x22 << ((_n==1)?1:0));
}
near = (_n==0)? near : byte(near|0x1);
if ((mFlags>>_n & 1) == 0) {
near = byte(near & mFlags & ((_f == -1)? 0xFF : (0x1 << _f) ^ 0xFF));
} else {
mFlags = byte(mFlags ^ (0xFF & mFlags & (1<<_n)));
near = byte(near & ((_f == -1)? 0xFF : (0x1 << _f) ^ 0xFF));
}
IntList nearL = new IntList();
for (byte t = near, i = 0; i < 7; i++, t = byte(t>>1)) {
if ((t & 0x1) == 1) {
nearL.append(i);
}
}
int splitInto = 1;
if (mCounter > 1 && nearL.size() > 1 && _f == -1) {
splitInto = 2;
}
mCounter -= splitInto;
for (int i = 0; i < splitInto; i++) {
int t = nearL.get((PRN() + i + _f) % nearL.size());
Lines.add(new Line(4, _n, 4, t));
startNest(_n, t);
}
}
}
class Line {
PVector s, e;
Line(PVector _s, PVector _e) {
s = _s;
e = _e;
}
Line(int _sl, int _sn, int _el, int _en) {
s = new PVector(_sl, _sn);
e = new PVector(_el, _en);
}
}
PVector Coor2XY(int _l, int _n) {
_n = (_l!=0)? _n % (_l*6) : _n;
while (_n<0) {
_n += _l * 6;
}
PVector r = new PVector();
if ((_l == 0)||(_l == 4 && _n == 0)) {
r.x = 200;
r.y = 200;
return r;
} else if (_n % _l == 0 || _l == 4) {
_n = (_l == 4)? _n-1 : _n;
_l = (_l == 4)? 1 : _l;
float deg = -60;
deg += 60 * _n/_l;
r.x = _l * hgr * cos(radians(deg));
r.y = _l * hgr * sin(radians(deg));
r.x += 200;
r.y += 200;
return r;
} else {
float deg = -60;
deg += 60 * int(_n/_l);
r.x = _l * hgr * cos(radians(deg));
r.y = _l * hgr * sin(radians(deg));
r.x += 200;
r.y += 200;
deg += 120;
r.x += (_n % _l) * hgr * cos(radians(deg));
r.y += (_n % _l) * hgr * sin(radians(deg));
return r;
}
}
int PRN() {
int r = 1987 * (day() + minute() * 11 + hour() * 79);
return r;
}
void drawAllPoints() {
noStroke();
fill(mc);
PVector t;
t = Coor2XY(0, 0);
ellipse(t.x, t.y, scs, scs);
for (int i = 0; i < 6; i++) {
t = Coor2XY(1, i);
ellipse(t.x, t.y, scs, scs);
}
for (int i = 0; i < 12; i++) {
t = Coor2XY(2, i);
ellipse(t.x, t.y, bcs, bcs);
}
for (int i = 0; i < 18; i++) {
t = Coor2XY(3, i);
ellipse(t.x, t.y, scs, scs);
}
}
void MBlur(int _r, int _t) {
for (int i = 0; i < _t; i++) {
Blur(_r);
}
}
void Blur(int _r) {
HBlur(_r);
VBlur(_r);
}
void HBlur(int _r) {
color[] B = new color[400];
int CS, oi, ni, si, ei;
float div;
div = 1 / float(_r+_r+1);
loadPixels();
for (int j = 0; j < 400; j++) {
CS = 0;
loadPixels();
oi = si = j * 400;
ei = si + 400 - 1;
ni = si + _r;
for (int i = 0; i < _r + 2; i++) {
CS += pixels[si] & 0xFF;
}
for (int i = 0; i < _r + 1; i++) {
CS += (pixels[ni++] & 0xFF) - (pixels[oi] & 0xFF);
B[i] = color(CS*div);
}
for (int i = _r + 1; i < 400 - _r - 1; i++) {
CS += (pixels[ni++] & 0xFF) - (pixels[oi++] & 0xFF);
B[i] = color(CS*div);
}
for (int i = 400 - _r - 1; i < 400; i++) {
CS += (pixels[ei] & 0xFF) - (pixels[oi++] & 0xFF);
B[i] = color(CS*div);
}
for (int i = 0; i < 400; i++) {
pixels[i+si] = B[i];
}
updatePixels();
}
}
void VBlur(int _r) {
color[] B = new color[400];
int CS, oi, ni, si, ei;
float div;
div = 1 / float(_r+_r+1);
loadPixels();
for (int j = 0; j < 400; j++) {
CS = 0;
loadPixels();
oi = si = j;
ei = si + (400-1)*400;
ni = si + _r * 400;
for (int i = 0; i < _r + 2; i++) {
CS += pixels[si] & 0xFF;
}
for (int i = 0; i < _r + 1; i++) {
CS += (pixels[ni] & 0xFF) - (pixels[oi] & 0xFF);
ni+=400;
B[i] = color(CS*div);
}
for (int i = _r + 1; i < 400 - _r - 1; i++) {
CS += (pixels[ni] & 0xFF) - (pixels[oi] & 0xFF);
ni+=400;
oi+=400;
B[i] = color(CS*div);
}
for (int i = 400 - _r - 1; i < 400; i++) {
CS += (pixels[ei] & 0xFF) - (pixels[oi] & 0xFF);
oi+=400;
B[i] = color(CS*div);
}
for (int i = 0; i < 400; i++) {
pixels[400*i+si] = B[i];
}
updatePixels();
}
}
Thanks!
Edit: I’m not using the blur function I wrote, currently I’m using the filter(BLUR) but still get the same error.