Braiding the surface with silk threads

Dear fellow experimenters.
I ask for your help to change the algorithm Kristof Crolla.
BSL_GH_085_FreiOtto’ (119.4 KB)
It is required that it could work on a surface, for example, on a sphere or inside a closed curve.
I think it’s possible, but I don’t know how to do it.