Transform path to follow an arc

It was a bit hard to follow the code so I just rewrote a quick sketch to try to simulate what you wanted. In essence I just drew a circle and modulated the radius. You can play around with the calc_radius to get the effect you want. I haven’t learned tweak mode yet, but I guess this is a perfect use case for it.

void setup() {
  
  size(400,500);
  background(0);
  stroke(255);
}

void draw()
{
  float radius = 100.f;
  int center_x = width/2;
  int center_y = height/2;
  float step = 2 * PI / 360;
  
  for (float i = 0; i < 2 * PI; i += step) {
  float x0, y0, x1, y1;
  x0 = calc_radius(radius, i) * sin(i);
  y0 = calc_radius(radius, i) * cos(i);
  x1 = calc_radius(radius, i+step) * sin(i+step);
  y1 = calc_radius(radius, i+step) * cos(i+step);
  
    line(x0 + center_x, y0 + center_y, x1 + center_x, y1 + center_y);
    
  }
  
}

float calc_radius(float base, float rad){
  return 20 * sin(rad * 4.0f) + base;
}
1 Like