Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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