Skip to content

Instantly share code, notes, and snippets.

View treboc's full-sized avatar

Marvin Lee Kobert treboc

View GitHub Profile
@twostraws
twostraws / SpriteKit-SwiftUI-Metaballs.swift
Created June 16, 2025 14:05
A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
//
// A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
// The effect is created by having hundreds of physics-enabled balls in a SpriteKit scene,
// all drawing nothing. These balls are then read back out by SwiftUI in a TimelineView, and
// drawn using blur and alpha threshold filters to make them appear to be a liquid.
// The SpriteKit scene then has its gravity changed dynamically using the accelerometer,
// meaning that the "liquid" splashes around as you tilt your phone.
//
// Created by Paul Hudson
// https://www.hackingwithswift.com/license
@aataraxiaa
aataraxiaa / UITextView+NewHeight.swift
Last active September 22, 2023 16:35
UITextView extension with method to calculate new height based on content
extension UITextView {
/**
Calculates if new textview height (based on content) is larger than a base height
- parameter baseHeight: The base or minimum height
- returns: The new height
*/
func newHeight(withBaseHeight baseHeight: CGFloat) -> CGFloat {