开发者

Quartz2D good way to Draw point or line on touch?

I'm trying to develop an app that requires drawing based on user touch. I'm using Quartz2D a开发者_如何转开发nd CoreGraphics for drawing, now I'm wondering what's a good way to manage the points that i'm drawing? Currently I'm adding each touchMoved point to an array and setNeedsDisplay them on every move. This lags the system very fast. So Therefore I'm wondering if anyone know a good way to draw smoothly with user touch for a good amount of time? Thanks!


Touch events are fired very frequently. since quartz2d is slow your system will saturate.

several options

  • Switch to opengl ^^ (bu that is an overkill)

  • don't do a draw on every single event. put you touch to sleep (acutally thats an android soluiton so I'm not sure its good for Iphone), only draw 1 out of x lines.

  • store the coordinates of your touch somewhere and when your app is ready to refresh the ui, get the current values stored and do you draw.

  • another solution I had put in place is to test if the new position had actually moved of more that a certain amount from the las draw (lets say 1~3 px) this way I avoid refreshing and redrawing if the updated position was to small.

This are just pointers, there might be a better option for you case ^^

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜