Skip to content

Instantly share code, notes, and snippets.

@jsmmth
jsmmth / flags.css
Last active July 8, 2025 13:58
CSS Flags
/* Flags */
.flag {
display: flex;
width: 28px;
height: 28px;
align-items: center;
justify-content: center;
}
.flag:after {
import UIKit
import CoreImage
public extension UIImage {
/// Draws a rounded, solid‐color outline around this image’s alpha shape,
/// then composites the full-color image back in the center.
///
/// - Parameters:
/// - strokeColor: the color of the ring
/// - strokeWidth: the thickness of the ring (in points)
@jsmmth
jsmmth / Coordinator.swift
Last active July 20, 2025 08:01
Liquid Gradient Coordinator
import Metal
import MetalKit
import SwiftUI
final class Coordinator: NSObject, MTKViewDelegate {
// MARK: Metal setup
private let device: MTLDevice
private let commandQueue: MTLCommandQueue
private let pipeline: MTLRenderPipelineState
@jsmmth
jsmmth / Swift UI StarField Experiment
Created July 13, 2025 15:46
Pretty messy, probably quite un-optimised fun SwiftUI star field experiment.
import SwiftUI
import MetalKit
import simd
// MARK: - Metal View
struct MetalStarfieldView: UIViewRepresentable {
@Binding var speed: Double
@Binding var cameraShake: CGSize
let hyperdriveCallback: () -> Void
@jsmmth
jsmmth / ContentView.swift
Last active July 26, 2025 18:59
SwiftUI Animated Dashed Border
import SwiftUI
struct AnimatedBorder: View {
@State private var phase: CGFloat = 0
let cornerRadius: CGFloat = 25
let dashPattern: [CGFloat] = [15, 15]
let lineWidth: CGFloat = 4
var body: some View {
ZStack {