从用户的触摸中绘制一个完美的圆圈 - Draw a perfect circle from user's touch

问题:

I have this practice project that allows the user to draw on the screen as they touch with their fingers.我有这个练习项目,它允许用户在用手指触摸时在屏幕上绘图。 Very simple App I did as an exercise way back.我做的非常简单的应用程序作为一种锻炼方式。 My little cousin took the liberty of drawing things with his finger with my iPad on this App (Kids drawings: circle, lines, etc, whatever came to his mind).我的小表弟冒昧地用我的 iPad 在这个应用程序上用他的手指画东西(儿童画:圆、线等,无论他想到什么)。 Then he started to draw circles and then he asked me to make it a "good circle" (from my understanding: make the drawn circle perfectly round, as we know no matter how stable we try to draw something with our finger on the screen, a circle is never really as rounded as a circle should be).然后他开始画圆圈,然后他让我把它画成一个“好圆圈”(根据我的理解:把画的圆圈画成完美的圆形,因为我们知道无论我们用手指在屏幕上画东西有多稳定,圆圈永远不会像圆圈应该的那样圆润)。

So my question here is that, is there any way in code where we can first detect a line drawn by the user that forms a circle and generate approximately the same size of the circle by making it perfectly round on the screen.所以我的问题是,在代码中是否有任何方法可以让我们首先检测用户绘制的一条直线,该直线形成一个圆,并通过在屏幕上使其完美圆形来生成大致相同大小的圆。 Making a not so straight line straight is something I would know how to do, but as for circle, I don't quite know how to go about doing it with Quartz or other methods.使一条不那么直线的直线是我知道该怎么做的事情,但至于圆,我不太知道如何用 Quartz 或其他方法来做。

My reasoning is that, the start and the end point of the line must touch or cross each other after the user lifts his finger to justify the fact that he was trying to actually draw a circle.我的推理是,在用户擡起手指以证明他试图实际画圆后,线的起点和终点必须相互接触或交叉。


解决方案:

参考一: https://en.stackoom.com/question/1HRo5
参考二: https://stackoom.com/question/1HRo5
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章