Converting JS (DTwitter) code into Processing

So I’ve done this now and it definitely looks like something but not like the original sketch. So I must have made a mistake somewhere. If I can find it, I’ll send a new version.

void setup() {
  size(500, 500);
}

void draw() {
  background(255);
  
  noFill();
  stroke(0);
  strokeWeight(1);
  u(millis() / 1000f);
}

void T(float t, float[] A) {
  T(t, A, 0);
}
void T(float t, float[] A, int i) {
  t += 1;
  T(t, A, i, 0, sin(t)/3 + 0.5);
}
void T(float t, float[] A, int i, float z, float p) {
  i++;
  if(i > 12) {
    rect(A[0], A[1], A[2], A[3]);
  }else{
    float[] param1 = new float[A.length];
    arrayCopy(A, param1);
    
    int param2 = i;
    
    A[2 + i%2] *= p;
    z = A[2 + i%2];
    float param3 = z;
    
    T(t, A, i);
    
    i %= 2;
    A[i] += z;
    
    A[2 + i] = z/p - z;
    
    T(t,
      param1,
      param2,
      param3,
      0
    );
  }
}
void u(float t) {
    T(t, new float[]{
        0, // 1st elem
        0, // 2nd elem
        width, // 3th elem
        height // 4th elem
    });
}
1 Like