Skip to content

Instantly share code, notes, and snippets.

@jacobjoaquin
Last active November 20, 2017 23:00
Show Gist options
  • Save jacobjoaquin/7631f6bb4f67f5d4231a to your computer and use it in GitHub Desktop.
Save jacobjoaquin/7631f6bb4f67f5d4231a to your computer and use it in GitHub Desktop.
Simple circle in circle illusion.
int c = 255;
float angle = 0;
void setup() {
size(500, 500);
noStroke();
}
void draw() {
background(0);
translate(width / 2, height / 2);
c = 255;
cic(width / 2, 10, angle, PI / 16.0);
angle += PI / 48.0;
}
void cic(float radius, float rSub, float angle, float aAdd) {
fill(c);
c = 255 - c;
ellipse(0, 0, radius * 2, radius * 2);
radius -= rSub;
angle += aAdd;
PVector p = PVector.fromAngle(angle + aAdd);
p.mult(rSub * 0.6);
translate(p.x, p.y);
if (radius >= 1) {
cic(radius, rSub, angle, aAdd);
}
}
int c = 255;
float angle = 0;
void setup() {
size(500, 500);
noStroke();
}
void draw() {
background(0);
translate(width / 2, height / 2);
c = 255;
float rSub = map(mouseX, 0, width, 5, 20);
float aAdd = map(mouseY, 0, height, PI / 2.0, PI / 48.0);
cic(width / 2, rSub, angle, aAdd);
angle += PI / 23.0;
}
void cic(float radius, float rSub, float angle, float aAdd) {
fill(c);
c = 255 - c;
ellipse(0, 0, radius * 2, radius * 2);
radius -= rSub;
angle += aAdd;
PVector p = PVector.fromAngle(angle + aAdd);
p.mult(rSub * 0.6);
translate(p.x, p.y);
if (radius >= 1) {
cic(radius, rSub, angle, aAdd);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment