I am trying to make an abstract kind of object i guess, referencing the book processing creative coding examples

Viewed 33

Here is the code, i can get screenshots of everything if need be, but Im just getting one error - "syntax error you might be mixing active and static modes."

Im fairly new to this so any help would be great.

float boxSize = 40;
float margin = boxSize*2;
float depth = 400;
color boxFill;
void setup(){
size(500,500,P3D);
}

void draw(){
translate(width/2, height/2, -depth/2);
rotateY(frameCount*PI/60);
rotateX(frameCount*PI/60);
}
for (float i=-depth/2+margin; i<=depth/2-margin; i+=boxSize){
pushMatrix();
for (float j=-height/2+margin; j<=height/2-margin; j+=boxSize){
pushMatrix();

for (float k=-width/2+margin; k<=width/2-margin; k+=boxSize){
  boxFill = color(abs(i), abs(j), abs(k), 50);
pushMatrix();
translate(k, j, i);
fill(boxFill);
box(boxSize, boxSize, boxSize);
popMatrix();
}
popMatrix();
}
popMatrix();
}
}
1 Answers

I recommend formatting your code first: Processing > Edit > Auto Format (CMD+T / Ctrl+T)

This will reveal this error right after the rotateX() call:

Missing left curly bracket "{"

What it actually means is that you have an extra } and it shouldn't be (as the for loop after should be part of the draw() function:

float boxSize = 40;
float margin = boxSize*2;
float depth = 400;
color boxFill;

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

void draw() {
  translate(width/2, height/2, -depth/2);
  rotateY(frameCount*PI/60);
  rotateX(frameCount*PI/60);

  for (float i=-depth/2+margin; i<=depth/2-margin; i+=boxSize) {
    pushMatrix();
    for (float j=-height/2+margin; j<=height/2-margin; j+=boxSize) {
      pushMatrix();

      for (float k=-width/2+margin; k<=width/2-margin; k+=boxSize) {
        boxFill = color(abs(i), abs(j), abs(k), 50);
        pushMatrix();
        translate(k, j, i);
        fill(boxFill);
        box(boxSize, boxSize, boxSize);
        popMatrix();
      }
      popMatrix();
    }
    popMatrix();
  }
}
Related