I am working on creating a way for a user to move polygons on screen and change their shape by dragging their corner vertices. I then need to be able to re-draw those modified polygons on other devices - so I need to be able to get final positions of all vertices for all polygons on screen.
This is what I am currently doing:
I draw polygons using UIBezierPath
for each shape in the override of the drawRect
function. I then allow user to drag them around the screen by applying CGAffineTransformMakeTranslation
function and the x
and y
coordinate deltas in touchedMoved
function override. I have the initial control points from which initial polygons are drawn (as described here). But once a path instance is moved on screen, those values don't change - so I am only able to get initial values.
Is there something built - in in the Core Graphics
framework that will allow me to grab a set of current control points in a UIBezierPath
instance? I am trying to avoid keeping track of those points manually. I will consider using other ways to draw if:
- there is a built - in way to detect if a point lies within that polygon (such as
UIBezierPath#contains
method - A way to easily introduce constraints so user can't move a polygon out of bounds of the superview (I need the whole polygon to be visible)
- A way to grab all points easily when user is done
- Everything can run under 60fps on iPhone 5.
Thanks for your time!