int rectCount = 5; void setup() { size(512, 200); } void draw() { background(255); noStroke(); rectMode(CENTER); float spacing = width / rectCount; float paddingLeft = spacing / 2; for (int i = 0; i < rectCount; i++) { fill(192, 64, 64); rect(paddingLeft + spacing*i, height/2, 50, 50); } }