Currently, I am working on my bachelor thesis which will be an automata editor for iPad. I needed to recognize some shapes drawn by the user and for that I am using the exquisite framework by Apple, CoreML. But I also needed to create a custom dataset for some of the shapes - and I could not find anything that fit my needs!
I needed quite a simple app, actually:
- it should be for iPad
- I want to use my Apple Pencil to draw given shapes
- exporting images to iPad Files app
- scaling the image to a given size
- making the image grayscale
Well, as you might have guessed from the title - I have not found anything that fit those needs. Alas I built my own solution!
It turned out to actually be easier than I expected.
Long story short, I had to
PKCanvasViewand wrap it to
UIViewRepresentable, so I could use it in SwiftUI
- Add export button and
TextEditorfor specifying resulting image size
- convert image to desired size + to grayscale
- save it to documents 🥳
You can check out the code on Github.
To install it on your device, download the code and install it via Xcode. I did think about putting it on AppStore, and I still might do so in the future, but for the time being I’ll keep it on Github only 🙂
Let me know if you’d like to see any improvements or if you stumble upon any issues!
Below, you can see a quick GIF showing off the functionality: