How do I create regular spirograph curves around an asymmetrical shape

This below is my attempt to address your question. I also did some minor changes. This could come handy. I also think these links could be relevant to your question:

Additive Wave / Examples / Processing.org
https://forum.processing.org/two/discussion/21356/how-to-draw-waves-like-those-in-the-pictures
Wave displaced circle - #5 by josephh

Your question is an interesting challenge. I might give it a try this weekend if you are still looking for help.

@kll Your demo produces interesting patterns :raising_hand_man:

Kf

int d=2,  r=1;
float  x=0, y=0, t;

void setup() {
  size(800, 800);
  surface.setTitle("Use mouseX mouseY and mouse wheel");
  
  stroke(0);
  strokeWeight(1.5);
}

void draw() {
  background(255);  
  translate(width/2, height/2);
  
  float R=mouseX/10;
  float O=mouseY/2;
  
  beginShape();
  for ( int i=0; i<360; i++) {
    t = radians(i);
    x = (x/50+y/50000)*(R+r)*cos(t) - (r+O)*cos(((R+r)/r)*t);
    y = (R+r)*sin(t) - (r+O)*sin(((R+r)/r)*t);
    curveVertex(x,y);
  }
  endShape();
}

void mouseWheel(MouseEvent event) {
  r += event.getCount();
  if ( r <= 10 ) r = 10;
  println("r: “+r+” R: “+R+” O: "+0);
}
1 Like