從用戶的觸摸中繪製一個完美的圓圈 - 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章