# Transform path to follow an arc

**URL:** <https://discourse.processing.org/t/transform-path-to-follow-an-arc/22166>\
**Category:** Coding Questions\
**Created:** [June 25, 2020, 5:25pm UTC](https://discourse.processing.org/t/transform-path-to-follow-an-arc/22166 "2020-06-25T17:25:05Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![furinax](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/furinax/32/9699_2.png) [@furinax](https://discourse.processing.org/u/furinax)\
**Post date:** [June 26, 2020, 5:18am UTC](https://discourse.processing.org/t/transform-path-to-follow-an-arc/22166/2 "2020-06-26T05:18:00Z")

</div>

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.

```auto
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;
}

```

---

_[View the full topic](https://discourse.processing.org/t/transform-path-to-follow-an-arc/22166)._
