Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/czajnikowski/segmentationeffect
Some SwiftUI + Metal geometry effect
https://github.com/czajnikowski/segmentationeffect
ios17 macos14 metalapi swiftui
Last synced: 3 months ago
JSON representation
Some SwiftUI + Metal geometry effect
- Host: GitHub
- URL: https://github.com/czajnikowski/segmentationeffect
- Owner: Czajnikowski
- License: mit
- Created: 2024-03-05T12:27:59.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-06-11T15:47:13.000Z (8 months ago)
- Last Synced: 2024-10-14T06:47:31.017Z (4 months ago)
- Topics: ios17, macos14, metalapi, swiftui
- Language: Swift
- Homepage:
- Size: 32.2 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SegmentationEffect
This effect allows you to transform the geometry of your regular, rectangular SwiftUI `View`s into quadrilateral segments ⏢, so you can do fun things like:
![output](https://github.com/Czajnikowski/SegmentationEffect/assets/973682/58ee8392-45c1-43a1-b655-c9d81764a50a)
The shader uses bilinear interpolation to map pixel positions to the output via `View.distortionEffect`. The repository features an editor app that allows you to give it a try in an interactive way.
## How To Use It?
Use as a Swift Package.
Use a [`View.segmentationEffect`](https://github.com/Czajnikowski/SegmentationEffect/blob/main/Sources/SegmentationEffect/SegmentationEffect.swift#L4-L19) modifier.
## Why?
I made it mostly for myself as an exercise in my recent `SwiftUI` + `Metal` research. At this point APIs have not been crafted very carefully, so the possibilities of the package are quite limited, but give it a try, and be sure to let me know if you like it. I can definitely spend some more time on it, if it is of use for anybody in a real project. At this point - it simply "works for me™️" ⏸️😁
Feel free to use it, feel free to contribute (fix issues, share ideas), and feel free to hit me up [@czajnikowski](https://twitter.com/czajnikowski) 👋