position polygon accurately? (relative to known vertices - issue is it creates it own centre)

Question: How can one position a polygon relative to one of it’s known vertice points?  

In other words how could I calculate where the auto generated center of the polygon is relative to one of the known vertices (i.e. used in the path)?    

e.g. Image placing a specific shape on a map which you make polygon, you then want to position it on the map, however you can’t do this accurately without knowing where it’s Corona engine created centre is.  Extract from API:  “The local origin is at the center of the polygon and the anchor point is initialized to this local origin.”

PS Actually wondering if I should be using a line and appending points to create effectively a polygon, however perhaps you can’t add background color in this case(?)

I once answered a similar question:

https://www.youtube.com/watch?v=8qUPspALWAY

Code in post:

https://forums.coronalabs.com/topic/49570-displaynewpolygon-path/#entry256518

You’ll need to take the code I provided and take it a step further.  i.e. Calculate relative position for the shape based on the position of the vertex as compared to the object’s center (as reported by Corona)

thanks roaminggamer - so looks like there’s no way in the API then and you have to calculate the centre yourself right?  Mind if I double-check my understanding with you here:

a) so using a polygon is the only way forward here if I want to add fill color? (i.e. can’t do this with a line with appended points it seems)

b) there would be a risk if Corona change the way they calculate the center then your app graphics would be out of whack?  i.e. you’d have to change your own calculation to match?

c) wondering if it’s a reasonable feature request, e.g. something like “getCenterOffsetFromFirstVertexPoint”?

thanks

Well, I don’t use it much so I’m not an expert , but in my experience it can create shapes that seem to have an arbitrary center.

Anything is a reasonable request, but it will have to get more votes than other features, which is kinda iffy  :unsure:

Sorry I could not be more help on this.

I once answered a similar question:

https://www.youtube.com/watch?v=8qUPspALWAY

Code in post:

https://forums.coronalabs.com/topic/49570-displaynewpolygon-path/#entry256518

You’ll need to take the code I provided and take it a step further.  i.e. Calculate relative position for the shape based on the position of the vertex as compared to the object’s center (as reported by Corona)

thanks roaminggamer - so looks like there’s no way in the API then and you have to calculate the centre yourself right?  Mind if I double-check my understanding with you here:

a) so using a polygon is the only way forward here if I want to add fill color? (i.e. can’t do this with a line with appended points it seems)

b) there would be a risk if Corona change the way they calculate the center then your app graphics would be out of whack?  i.e. you’d have to change your own calculation to match?

c) wondering if it’s a reasonable feature request, e.g. something like “getCenterOffsetFromFirstVertexPoint”?

thanks

Well, I don’t use it much so I’m not an expert , but in my experience it can create shapes that seem to have an arbitrary center.

Anything is a reasonable request, but it will have to get more votes than other features, which is kinda iffy  :unsure:

Sorry I could not be more help on this.