How to generate TexCoord properly?

Hi!
I have a question about texCoord. I would like to generate meshes with ofPath and using shaders (Bezier, and abstract shapes) also i would like to connect vertices randomly according rules.
but I realized that i have to generate texCoord and pass it to the shader in order to use uv coordinates in the fragment stage.

Is there any formula to generate texCoord of non-regular shapes (like beziers or some others polygons) ? How is the logic?
Until now, i ve been using ofPrimitiveSphere and Plane, and its texCoords are passed automatically to the shader.
Thanks!

I Would probably map your random shape inside a square, and then map it accordingly. You have to imagine your shape spread on a 2D surface, where each point can be defined using only x an y coordinate.