Skip to content

Latest commit

 

History

History
14 lines (10 loc) · 710 Bytes

README.md

File metadata and controls

14 lines (10 loc) · 710 Bytes

AuroraView

Showcasing a technique used to create performant Aurora gradients (blurred blobs) in SwiftUI on macOS.

Aurora View

Problem

To achieve this effect in SwiftUI, you would typically create Shapes and using the .blur modifier. This would incur a heavy performance penalty while animating (up to 50% CPU).

Solution

By using a CALayer and Core Animation to animate the blobs, we can offload all the work to the WindowServer & GPU. The result is an app CPU utilization of 0%. A CALayer overlay is also used as a noise filter to smooth out the banding artifacts that are common in blurred color gradients. A NSViewRepresentable is used to make everything accessible from SwiftUI.