Skip to content

About

🕸️ Brings a Spider-Verse like glitching effect to your SwiftUI views!

Topics

Resources

Stars

23 stars

Watchers

3 watching

Forks

Repository files navigation

🕸️ Spiderversify

Spider-Verse glitch for SwiftUI, drawn by Metal shaders.

Inspired by the look of Sony Pictures' Spider-Man: Into the Spider-Verse and Across the Spider-Verse: misprinted ink, Ben-Day dots, torn frames, and portals into other dimensions. One modifier, any view.

Swift 5.9 iOS 17+ macOS 14+ tvOS 17+ visionOS 1+ SPM MIT

portal glitch typeface

Portal with the Miles palette · the default glitch on a card with Gwen · typeface swaps with Hobie

Quick start

import SwiftUI
import Spiderversify

struct ContentView: View {

  @State private var glitching = false

  var body: some View {
    Text("Spiderversify")
      .spiderversify($glitching) // 🕸️
      .font(.largeTitle.bold())
      .onTapGesture {
        glitching = true
      }
  }
}

Tap the text and it glitches for 1.5 seconds, then settles back on its own.

What it does

Every effect is a Metal shader applied to the rasterized view, so it works on text, images, buttons, cards, whatever you give it, and it never changes the view's layout.

Effect What you see
Misprint Two offset ink ghosts and a red/blue channel split, like a comic page printed out of register
Halftone Ben-Day dots inside the first ink ghost
Stripes Diagonal hatching inside the second ink ghost
Slices Horizontal bands torn sideways
Jitter Small shakes and tilts, held for each frame
Typeface Swaps the font design and weight every frame (Text only)
Portal A tunnel of twisted rings that pulls the view into another dimension, with a tap for every ring

It animates on twos by default, 12 frames per second, the way Miles moves in the films. When the glitch ends, it fades out over half a second instead of stopping dead, and the portal collapses ring by ring.

Three ways to start it

// A binding: plays once when set to true, then sets it back to false.
.spiderversify($glitching, duration: 2)

// A trigger: plays once each time the value changes, like sensoryFeedback(_:trigger:).
.spiderversify(trigger: tapCount)

// A flag: keeps glitching for as long as it is true.
.spiderversify(isActive: isLoading)

Styles

Pass a SpiderverseStyle to pick the effects, strength, timing, and inks.

.spiderversify($glitching, style: .portal)

.spiderversify(trigger: tapCount, style: SpiderverseStyle(
  effects: [.misprint, .halftone, .slices],
  intensity: 1.4,
  framesPerSecond: 12,
  palette: .gwen
))
Parameter Default Notes
effects .glitch Any mix of .misprint, .halftone, .stripes, .slices, .jitter, .typeface, .portal. .glitch is the first five; .all adds the rest.
intensity 1 Scales every offset, tear, and shake
framesPerSecond 12 How often the glitch changes. 24 is "on ones", 12 is "on twos", 8 is "on threes"
palette .random .miles, .gwen, .hobie, .prowler, or .custom(_:_:). .random picks one each time the effect starts
haptics true A tap for each portal ring as it arrives and leaves

Presets: .default, .subtle, .portal.

Palettes: each one is two inks, used for the misprint ghosts and the portal.

First ink Second ink
.miles red sky blue
.gwen pink teal
.hobie yellow magenta
.prowler violet green

Good to know

  • Reduce Motion: with the accessibility setting on, the glitch holds a single still frame instead of flickering, and the portal skips its animation.
  • UIKit and AppKit views: the shaders render the view into a layer, so views backed by UIKit or AppKit (such as TextField) show a placeholder while glitching.
  • Timing: a one-shot glitch stays on screen for duration plus a half-second fade.
  • Portal size: the portal is drawn around the view and spills past its bounds on purpose, like the films.
  • Haptics need a device; the simulator stays quiet. Turn them off with SpiderverseStyle(haptics: false).

Demo

The Demo folder has an app with every effect behind a toggle, the presets, intensity and frame rate controls, and light and dark modes. Open Spiderversify.xcworkspace and run the Demo scheme.

Installation

Spiderversify supports Swift Package Manager.

In Xcode, choose File → Add Package Dependencies… and enter:

https://github.com/Jager-yoo/Spiderversify.git

Or add it to your Package.swift:

dependencies: [
  .package(url: "https://github.com/Jager-yoo/Spiderversify.git", from: "2.0.0")
]

Requires iOS 17, macOS 14, tvOS 17, or visionOS 1, and Xcode 15 or later. Versions before 2.0 support iOS 15 and are view-based rather than shader-based; pin to 1.0.0 if you need them.

License

Spiderversify is released under the MIT license. See LICENSE for details.

About

🕸️ Brings a Spider-Verse like glitching effect to your SwiftUI views!

Topics

Resources

Stars

23 stars

Watchers

3 watching

Forks

Releases

Contributors

Languages