How do you make a polygon of an indeterminate/redimensionable number of points?

I'd like to make a polygon and keep adding points to it, cause I don't know how many it will have

local points =

Keep track of your points in another table and every time there's a change delete and recreate the polygon using one of the below methods:, y1, x2, y2, ..., xn, yn), p2, ..., pn)

It's not ideal. But the process should be invisible to the user and for you some garbage collection churn.

It would be nice to have the ability to insert a point at an arbitrary place in the series of points of a polygon.


This means I have to use and set each index manually before drawing, which means 2 lists are kept instead of 1, which will affect performance...

I think I'll just have to skip using polygon and draw lines instead then.

That's all polygon does anyway?

Don't be sure of the affects on performance until you've tried it. Please report your benchmarks.

1 Like