# Object Following A Moving Bezier Graph

**URL:** <https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598>\
**Category:** Coding Questions\
**Created:** [June 9, 2021, 9:10am UTC](https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598 "2021-06-09T09:10:35Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![Nick76](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nick76/32/13590_2.png) [@Nick76](https://discourse.processing.org/u/Nick76)\
**Post date:** [June 12, 2021, 7:37am UTC](https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598/21 "2021-06-12T07:37:20Z")

</div>

It does 🥳 Can’t thank you enough for all your help!! 🙏

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [June 12, 2021, 8:17am UTC](https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598/22 "2021-06-12T08:17:21Z")

</div>

One last thing the last set of changes means we don’t need the `if` statement in `drawTrace()` so we have

```auto
void drawTrace() {
  stroke(traceCol);
  strokeWeight(16);
  float prevX, prevY, currX, currY;
  int pos = max(1, startIdx);
  prevX = pos * traceStep;
  prevY = trace[pos] * maxAmp;
  for (; pos < trace.length; pos++) {
    currX = pos * traceStep;
    currY = trace[pos] * maxAmp;
    line(prevX, midH + prevY, currX, midH + currY);
    prevX = currX;
    prevY = currY;
  }
}

```

Glad to have helped 😀

---

<div class="post-metadata">

**Author:** ![Nick76](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/nick76/32/13590_2.png) [@Nick76](https://discourse.processing.org/u/Nick76)\
**Post date:** [July 16, 2021, 1:24pm UTC](https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598/23 "2021-07-16T13:24:05Z")

</div>

Thanks for the hint 🙂

[Previous page](https://discourse.processing.org/t/object-following-a-moving-bezier-graph/30598.md?page=1)
