Trying to create wave / cloth flow pattern

Sure, res stands for ‘resolution’, it is the number of points contained in a single line.

You need to remember that these points are stored as vectors in a 1 dimensional array list:

points = [vector(10, 10), vector(10, 20), vector(10, 30), vector(10, 40), ...]

If you want to draw a line you need to connect the first vector to the second, the second to the third, the third to the fourth, and so on until you reach the end of the array.
However, if you do so, the last point of the first line will be connected to the first point of the second line, and this for each line.

In order to prevent this you need to stop the connexion mecanism at the end of each line. That’s what that line of code does:

if (id % res != (res - 1))
“as long as the current point is not the last point of a line” …(connect it to the next point)

Check the reference page of mudolo if that’s still obscure to you.

Here below a visual exaplanation with res = 5

Hope that helps

5 Likes