Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daprice/variablur
Variable blur effects for SwiftUI, powered by Metal
https://github.com/daprice/variablur
blur-ramp metal-shader progressive-blur swift-package swiftui variable-blur
Last synced: about 1 month ago
JSON representation
Variable blur effects for SwiftUI, powered by Metal
- Host: GitHub
- URL: https://github.com/daprice/variablur
- Owner: daprice
- License: mit
- Created: 2023-11-19T00:21:56.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2023-12-08T21:17:59.000Z (11 months ago)
- Last Synced: 2024-10-12T18:02:31.012Z (about 1 month ago)
- Topics: blur-ramp, metal-shader, progressive-blur, swift-package, swiftui, variable-blur
- Language: Swift
- Homepage: https://swiftpackageindex.com/daprice/Variablur
- Size: 309 KB
- Stars: 199
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Variablur
> [!NOTE]
> This code is now included in the project that inspired it, [twostraws/Inferno](https://github.com/twostraws/Inferno). Consider using that package instead, as any future improvements or additional shaders are likely to end up there.With Variablur, you can create variable blur effects that you control with a mask. Because you draw the mask using a `GraphicsContext`, it can contain gradients, shapes, text, pre-rendered images, or anything else you can draw into a `GraphicsContext`.
You can create gradient or progressive blurs, vignettes, "blur shadows", or many other effects.
![Example of a blurred snowflake background behind some demo UI.](Sources/Variablur/Documentation.docc/Resources/[email protected])
### More info
- The blur radius is controlled per pixel for a true variable gaussian blur effect
- Variablur uses 100% public API – it's just a Metal shader and a couple extensions to SwiftUI types
- In my testing it runs smoothly even when applied to large, animated views or combined with other shaders. If performance is an issue, there's an option to lower the sample count. That said, I'm sure it could be optimized further and would be grateful for a PR that improves performance.
- SwiftUI's visual effects can only be applied to pure SwiftUI views, and this library shares that limitation.## Examples
To see live examples of various effects you can achieve with different masks, clone this repository, open it in Xcode, and look in `Sources/Variablur/View+variableBlur.swift` for Xcode previews.
## Usage with Swift Package Manager
Add Variablur to your project: `https://github.com/daprice/Variablur`