Loading...
Logo
Processing Forum

Lilac Chaser

in Programming Questions  •  9 months ago  
Hey,

I'm trying to create the Lilac Chaser but I am having a pretty hard time implementing it.

This is the code I've got:

Copy code
  1. void drawCircles() { 
  2.   noStroke();
  3.   fill(182, 102, 210);
  4.   float radius = 190;
  5.   int numCircles = 12;
  6.   float angle = TWO_PI/(float)numCircles;
  7.   int discolor = 11;
  8.   for (int i = 0; i < numCircles; i++) {
  9.     ellipse(radius * sin(angle*i), radius * cos(angle*i), 40, 40);
  10.   }
  11. }

  12. void coverCircle(float rot) {
  13.   noStroke();
  14.   rotate(rot);
  15.   fill(170,170,170);
  16.   float radius = 190;
  17.   float angle = TWO_PI;
  18.   ellipse(radius*sin(angle),radius*cos(angle),50,50);
  19. }

  20. void setup() {
  21.   size(500, 500);
  22. }

  23. float rot = 0;

  24. void draw() {
  25.   background(170,170,170);
  26.   translate(width/2, height/2);
  27.   drawCircles();
  28.   coverCircle(rot);
  29.   rot += 0.08;
  30. }
Now, I realize that in the original Lilac Chaser, the circles disappear and appear in a way that they give the impression of a grey circle (and then a green circle) going around. I tried to create that by adding a background colored circle that goes around the 12 circles. But it ends up being pretty weird and not what I want.

I would really appreciate if you guys could help me out with this with ideas that I could try out. I am a noob at Processing so I would really appreciate it if your explanations were dumbed down for me.

PS: This is what I am trying to achieve in case you weren't familiar with the Lilac Chaser illusion:

Also I tried looking for a Processing implementation of Lilac Chaser over at openprocessing.org but couldn't find any. If you are familiar with such an implementation, I'd appreciate if you could direct me to it.

Replies(2)

Re: Lilac Chaser

9 months ago


very nice!


I made a version that just doesn't paint one circle.
It's number gets decreased and then starts all over.

You can also make the circles color weaker (line 3, 4th parameter in fill())

Copy code
  1. void drawCircles() {
  2.   noStroke();
  3.   fill(182, 102, 210, 70);
  4.   float radius = 190;
  5.   float angle = TWO_PI/(float)numCircles;
  6.   int discolor = 11;
  7.   for (int i = 0; i < numCircles; i++) {
  8.     if (i!=hidden)
  9.       ellipse(radius * sin(angle*i), radius * cos(angle*i), 40, 40);
  10.   }
  11. }
  12. //void coverCircle(float rot) {
  13. //  noStroke();
  14. //  rotate(rot);
  15. //  fill(170, 170, 170);
  16. //  float radius = 190;
  17. //  float angle = TWO_PI;
  18. //  ellipse(radius*sin(angle), radius*cos(angle), 50, 50);
  19. //}
  20. void setup() {
  21.   size(500, 500);
  22.   frameRate(6);
  23. }
  24. float rot = 0;
  25. int numCircles = 12;
  26. int hidden=numCircles;
  27. //
  28. void draw() {
  29.   background(170, 170, 170);
  30.   translate(width/2, height/2);
  31.   drawCircles();
  32.   //  coverCircle(rot);
  33.   rot += 0.08;
  34.   hidden--;
  35.   if (hidden>numCircles)
  36.     hidden=0;
  37.   if (hidden<0)
  38.     hidden=numCircles;
  39. }

Re: Lilac Chaser

9 months ago
Thanks Chrisir,

I guess I was on the right track with this but didn't think outside the box.

Thanks a lot. It worked perfectly.