Skip to content

Instantly share code, notes, and snippets.

@Enie
Enie / BrushedMetalDemoApp.swift
Last active August 19, 2024 14:28
Brushed Metal shader effect for SwiftUI
import SwiftUI
@main
struct BrushedMetalDemoApp: App {
var body: some Scene {
WindowGroup {
BrushedMetalView {
ContentView()
}
}
@Enie
Enie / AnimatedImage.swift
Last active September 5, 2023 20:32
Rendering animated gifs in SwiftUI.
import SwiftUI
public struct AnimatedImage: NSUIViewRepresentable {
public let animationImage: NSUIImage
public let isAnimating: Bool
#if os(iOS) || os(watchOS) || os(tvOS)
public func makeUIView(context: Context) -> UIImageView {
let imageView = UIImageView()
imageView.image = animationImage
import SwiftUI
import simd
struct Tick {
var position: CGPoint
var angle: Angle
}
func roundedRectTickCoordinates(count n:Int, in rect:CGRect, cornerRadius: CGFloat) -> [Tick] {
let width = rect.size.width