RippleEffect
Swift Package iOS 17+A Metal-backed radial ripple distortion for SwiftUI. Tap anywhere to warp pixels outward in a realistic water-ripple effect. One line to add, fully configurable.
Real pixel displacement via Metal
[[ stitchable ]] shader
Single-line API:
.rippleEffect(at:trigger:)
Configurable speed, amplitude, frequency, and band width
Edge fade option prevents artifacts at view boundaries
Auto-pausing TimelineView — zero GPU cost when idle
Includes a plug-and-play
RippleDemo scene
Usage
import RippleEffect struct MyView: View { @State private var touchPoint: CGPoint = .zero @State private var tapID = UUID() var body: some View { Image("photo") .rippleEffect(at: touchPoint, trigger: tapID) .simultaneousGesture( SpatialTapGesture() .onEnded { value in touchPoint = value.location tapID = UUID() } ) } }
Parameters
| Parameter | Default | Description |
|---|---|---|
| at | — | Origin point of the ripple (tap location) |
| trigger | — | Any Equatable value; ripple fires on change |
| amplitude | 24 | Max pixel displacement (higher = stronger) |
| speed | 400 | How fast the wave front expands (px/s) |
| frequency | 0.08 | Wave density (higher = tighter waves) |
| bandWidth | 50 | Width of the wave packet in pixels |
| duration | 1.8 | How long the ripple lasts in seconds |
| edgeFade | 0 | Pixels from edge where ripple fades to zero. 0 = full edges, 40–80 = smooth fade. |