Move your mouse anywhere in the graphics window to drag the center of the spinning pattern. For the most eye-popping effects, point near the middle of the graphics window.
This Moire effect is created with two identical black-and-white starburst patterns. One is fixed in place, while the other one moves with you. If you drag your mouse far enough you can see that the moving pattern is drawn inside a big circle.
void setup() {
size(600, 400);
smooth();
noStroke();
}
void draw() {
background(255);
fill(0);
pushMatrix(); // save things for the background pattern
translate(width/2, height/2); // move to middle of screen
drawStar(); // draw the background
popMatrix();
pushMatrix(); // save things for the foreground pattern
translate(mouseX, mouseY); // move to the mouse's location
rotate(TWO_PI * frameCount/800); // rotate over time
drawStar(); // draw the foreground
popMatrix();
}
void drawStar() {
int numSpokes = 100; // draw this many radiating spokes
for (int i=0; i<numSpokes; i++) {
float t0 = map(i, 0, numSpokes-1, 0, TWO_PI); // starting angle
float t1 = t0 + (TWO_PI/(2*numSpokes)); // ending angle
arc(0, 0, 1000, 1000, t0, t1); // draw this stroke
}
}