void setup () { // Set sketch to use P3D library for 3D images size(300, 300, P3D); background(50); } void draw () { background(50); if (mouseX > 50 && mouseX < 200) { fill(100, 175, 175); } else { fill(175, 100, 175); } // Draw rectangle w/ top left corner at (75, 75) // and width = height = 150 pixels translate(150, 150, -25); // Shift origin 150 px right and down, and 25 px back (into screen) rectMode(CENTER); rotateX(radians(mouseY)); // Rotate 45 degrees clockwise rotateY(radians(mouseX)); // Rotate left/right based on mouse position rect(0, 0, 20, 20); // Center rectangle over origin rect(-50, 0, 20, 20); rect(50, 0, 20, 20); }