Drawing app on iPad using OpenGL

前端 未结 2 2024
逝去的感伤
逝去的感伤 2021-01-30 03:27

I\'m creating a drawing app ( text ) for the iPad using OpenGL. I\'ve already had a look at Apple\'s example GLPaint, and my app is now based on that code. My app should be just

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 04:13

    With regards to the second part of your question (how to vary the width of the line depending on the speed of writing), you should be able to achieve this by taking advantage of UITouch's timestamp property in your touchesBegan:withEvent: and touchesMoved:withEvent: method.

    You can calculate the time difference between two subsequent touch events by storing the timestamp of the most recent UITouch object and comparing it to the new one. Dividing the distance of the swiping motion by the time difference should give you some measurement of the movement speed.

    Now all you need to do is to come up with a way to convert speed of writing into line width, which will probably come down to picking an arbitrary value and adjusting it until you're happy with the result.

提交回复
热议问题