Rotating circle segments

twirlyproblem.png

Hi all,

What I would like to achieve is circle segments that rotate on an axis.

My segments are currently built using polygons.

If the angle coverage is >270 it works fine as the middle is still the origin and rotating looks fine ( top left picture )

If the angle is small however, the rotation is off ( top right picture )

My workaround is to extend the polygon to the origin and set the anchor points there ( bottom picture )

This works fine but is not ideal.

I did not want to use full circles that are partially blocked off or semi circles with a full circle canvas as I did not want to block off the background.

Is there a way I can easily do this ? besides some serious mathing

Thanks in advance!

Search the forum for progressRing. Should work out of the box for you.

You can use a derivative of Jason’s progress ring or mine to make this happen.

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Tips_and_Tricks/dialTimer.zip

Note: My version can accommodate various masks and images. 

When you pass an array of vertices to newPolygon it computes the “true” bounds based on the vertex coordinates, then subtracts the center of those bounds from all vertices.  So any XY positioning you do will now position that polygon relative (based on its anchor) to the center of its content bounds.

All you need to do to correct the positioning is reverse what Corona did.  (cuz presently there’s no way to disable it)

It’ll take some code, but it’s pretty simple:  calculate the true bounds of your vertices yourself, then calculate the middle of those bounds, then store that coordinate on the object as a “delta” for later use.  If you “add in” that delta that Corona “took out” when positioning, then your poly will end up in the right place.

Thanks for the input guys,

Will look at the options and see what works best for me.

Thanks!

meant to post this earlier, to sort of “vouch” for the content-bounds-center-offset method if you choose to go that route (given that you apparently already have the ring segment code), but just fwiw… a frame from a video (work for hire milestone) where all the ring segments were offset polys probably much like yours, hth:

zs6tv.jpg

Hi Dave,

Thanks for the response.

Yes that’s what I tried to go with first.

I couldn’t figure out the math to make my functions completely generic but it works for angles 

90,180,>=270, which is good enough for me at the moment.

As I wanted the segments to be rotating, I found I had to change the AnchorX,Y values, did you also do that ?

I found when the angle is <90 for example, the bounds of the polygon does not extend to the center of the imaginary circle I am rotating around. 

I assume the AnchorX,Y values can only be set to a value within the bounds of my polygon.

Thanks in advance,

Search the forum for progressRing. Should work out of the box for you.

You can use a derivative of Jason’s progress ring or mine to make this happen.

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Tips_and_Tricks/dialTimer.zip

Note: My version can accommodate various masks and images. 

When you pass an array of vertices to newPolygon it computes the “true” bounds based on the vertex coordinates, then subtracts the center of those bounds from all vertices.  So any XY positioning you do will now position that polygon relative (based on its anchor) to the center of its content bounds.

All you need to do to correct the positioning is reverse what Corona did.  (cuz presently there’s no way to disable it)

It’ll take some code, but it’s pretty simple:  calculate the true bounds of your vertices yourself, then calculate the middle of those bounds, then store that coordinate on the object as a “delta” for later use.  If you “add in” that delta that Corona “took out” when positioning, then your poly will end up in the right place.

Thanks for the input guys,

Will look at the options and see what works best for me.

Thanks!

meant to post this earlier, to sort of “vouch” for the content-bounds-center-offset method if you choose to go that route (given that you apparently already have the ring segment code), but just fwiw… a frame from a video (work for hire milestone) where all the ring segments were offset polys probably much like yours, hth:

zs6tv.jpg

Hi Dave,

Thanks for the response.

Yes that’s what I tried to go with first.

I couldn’t figure out the math to make my functions completely generic but it works for angles 

90,180,>=270, which is good enough for me at the moment.

As I wanted the segments to be rotating, I found I had to change the AnchorX,Y values, did you also do that ?

I found when the angle is <90 for example, the bounds of the polygon does not extend to the center of the imaginary circle I am rotating around. 

I assume the AnchorX,Y values can only be set to a value within the bounds of my polygon.

Thanks in advance,