float r = 0; void setup() { size(200, 200); smooth(); rectMode(CENTER); } void draw() { background(255); fill(255, 0, 0); pushMatrix(); translate(50, 50); rotate(radians(mouseX)); rect(0, 0, 60, 60); popMatrix(); fill(0, 0, 255); pushMatrix(); translate(150, 150); rotate(r); rect(0, 0, 60, 60); popMatrix(); r += 0.04; }