https://github.com/owengombas/hand-drawing-swift-metal
✏️ Drawing engine with Swift and Metal (GPU)
https://github.com/owengombas/hand-drawing-swift-metal
cpu draw drawing gpu metal optimized performance swift
Last synced: 7 months ago
JSON representation
✏️ Drawing engine with Swift and Metal (GPU)
- Host: GitHub
- URL: https://github.com/owengombas/hand-drawing-swift-metal
- Owner: owengombas
- License: mit
- Created: 2019-08-03T15:57:21.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-08-08T22:22:42.000Z (about 6 years ago)
- Last Synced: 2024-05-19T11:08:05.375Z (over 1 year ago)
- Topics: cpu, draw, drawing, gpu, metal, optimized, performance, swift
- Language: Swift
- Homepage:
- Size: 63.5 KB
- Stars: 79
- Watchers: 8
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Draw on an iOS device using Metal ✏️
## TODOs and WIP tasks ✅
Look at the the project board [here](https://github.com/OwenCalvin/hand-drawing-swift-metal/projects/1)## How does it works 📟 ?
### Line system
A line is composed of a multitude of interconnected triangles, they are generated from **"key point"** which are **the points having as coordinates the places where you have slipped your finger/pen and handled by your device**. Several linked triangles can form a trapeze which allows to manage the force communicated with the apple pen in order to vary the width of the line on the same line.
*Image from [ios_metal_bezier_renderer](https://github.com/eldade/ios_metal_bezier_renderer)*

*From XCode debugger*### Interpolation
I use the Catmull Rom interpolation, it generates points between each **key points**
*With interpolation:*
*Without interpolation (only the **key points**):*
## See also
- [ios_metal_bezier_renderer](https://github.com/eldade/ios_metal_bezier_renderer)
- [Catmull–Rom spline interpolation](https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline)
- [Ramer-Douglas-Peucker algorithm](https://en.m.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm)
- [Helpful StackOverflow question](https://stackoverflow.com/questions/42889699/smooth-drawing-with-apple-pencil)