Skip to content

Czajnikowski/SegmentationEffect

Repository files navigation

SegmentationEffect

This effect allows you to transform the geometry of your regular, rectangular SwiftUI Views into quadrilateral segments ⏢, so you can do fun things like:

output

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 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 👋