There is always more than one way to do something, so here is an alternative approach that I used to animate your logo forwards and in reverse.

This is an assignment so I am not providing the full code solution rather an explanation of the algorithms I used.

The first thing I did was to represent the logo data in a 2D array

```
float[][] logoF = {
new float[] {150, 310, 150, -150, 225, 300, 130, 220},
new float[] {130, 220, 80, 150, 300, 10, 310, 160},
new float[] {310, 160, 330, 300, 195, 300, 200, 190},
new float[] {200, 190, 195, 110, 270, 110, 280, 170},
new float[] {280, 170, 290, 230, 240, 230, 240, 190},
new float[] {240, 190, 245, 150, 295, 150, 290, 230},
new float[] {290, 230, 295, 310, 195, 310, 185, 230},
new float[] {185, 230, 160, 60, 370, 60, 330, 280}
};
```

Each row represents a single Bezier curve, so we have 8 curves -

`logoF[0]`

, `logoF[1]`

, `logoF[2]`

, `logoF[3]`

, `logoF[4]`

, `logoF[5]`

, `logoF[6]`

and `logoF[7]`

We can create a reference to any of the curves like this

`float[] bc = logoF[n]; // where n is in the range 0-7 inclusive`

Once we have this reference we can access the control point data like this

```
bc = logoF[3]; // fourth curve
println(bc[0], bc[1]); // outputs 200, 190
```

Using arrays allows easy access all the Bezier control point coordinates. The next stage is to look at the algorithm to trace out the entire set of curves.

To represent a point on a Bezier curve we use a parametric variable which we will call `t`

. If we vary `t`

in the range 0.0 to 1.0 we can calculate any position on the curve.

In our logo we have 8 Bezier curves so we create a new parametric variable, `ct`

which varies between 0.0 and 8.0 inclusive. Consider the point `ct = 3.14`

the whole number part (can be zero) represents the individual Bezier curve and the decimal part the parametric position on that curve so we have

```
ct = 3.14;
cIdx = int(ct); // index = 3
bc = logoF[cIdx]; // reference to the coordinate array for the 4th Bezier curve
t = ct - cIdx; // parametric position = 0.14
```

So the algorithm for drawing the entire curve for a given `ct`

value is

Calculate the curve number (cIdx)
Calculate the parametric variable (t)
for every curve in the range >=0 and < cIdx
use the bezier function to draw the entire Bezier curve
Get a reference to the part traced curve (logoF[cIdx])
Draw this curve from 0.0 to `t`

You can use the same algorithm and code to draw the logo in reverse if you create a new 2D array (`logoR`

) and reverse the Binary curve order and for each Bezier curve reverse the coordinate **pairs**.