Skip to content

Instantly share code, notes, and snippets.

@lgastler
lgastler / BackgroundBlur.swift
Created February 23, 2023 08:53
BackgroundBlur
import SwiftUI
struct BackgroundBlob: View {
@State private var rotationAmount = 0.0
let alignment: Alignment = [.topLeading, .topTrailing, .bottomLeading, .bottomTrailing].randomElement()!
let color: Color = [.blue, .cyan, .indigo, .mint, .purple, .teal].randomElement()!
var body: some View {
Ellipse()
.fill(color)
extension Bundle {
func decode<T: Decodable>(_ type: T.Type, from file: String, dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate, keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys) -> T {
guard let url = self.url(forResource: file, withExtension: nil) else {
fatalError("Failed to locate \(file) in bundle.")
}
guard let data = try? Data(contentsOf: url) else {
fatalError("Failed to load \(file) from bundle.")
}