MyGit

heestand-xyz/MetalUI

Fork: 6 Star: 203 (更新于 1970-01-01 00:00:00)

license: MIT

Language: Metal .

Effects in SwiftUI

GitHub网址

MetalUI

Install

.package(url: "https://github.com/heestand-xyz/MetalUI", from: "0.1.0")

Gradient Blur

| | |

import SwiftUI
import MetalUI

struct ContentView: View {
    
    @State var radius: CGFloat = 0.0
    @State var curve: CGFloat = 1
    
    var body: some View {
        VStack {
            Slider(value: $radius, in: 0...100)
            Slider(value: $curve, in: 0...2)
            HStack(spacing: 0) {
                Color.red
                Color.yellow
                Color.green
                Color.cyan
                Color.blue
            }
            .padding()
            .gradientBlur(
                axis: .vertical,
                radii: [0.0, radius],
                curve: curve
            )
        }
    }
}

#Preview {
    ContentView()
}

GradientBlurStop can also be used for more fine grained control over the stops.

Green Screen

| | |

import SwiftUI
import MetalUI

struct ContentView: View {
    var body: some View {
        ZStack {
            Color.blue
                .ignoresSafeArea()
            Image("Superman")
                .resizable()
                .aspectRatio(contentMode: .fit)
                .chromaKey(color: Color(red: 0.0,
                                        green: 1.0,
                                        blue: 0.0))
        }
    }
}

#Preview {
    ContentView()
}

Kaleidoscope

https://github.com/heestand-xyz/MetalUI/assets/7947442/3eeb4a40-b578-4eb7-9700-3e34effe8e3d

import SwiftUI
import MetalUI

struct ContentView: View {
    
    @State var value: CGFloat = 0.0
    
    var body: some View {
        VStack {
            Color.red
            Color.green
            Color.blue
        }
        .frame(width: 200, height: 200)
        .kaleidoscope(count: 12, angle: .degrees(180))
    }
}

#Preview {
    ContentView()
}

Circle Blur

import SwiftUI
import MetalUI

struct ContentView: View {
    
    @State var value: CGFloat = 0.0
    
    var body: some View {
        VStack {
            Text("Hello World")
                .padding()
                .border(Color.black)
                .circleBlur(value * 10)
            Slider(value: $value)
        }
        .padding()
        .frame(width: 250)
    }
}

#Preview {
    ContentView()
}

Feedback

import SwiftUI
import MetalUI

struct ContentView: View {
    
    var body: some View {
        Text("Hello, World!")
            .foregroundStyle(.white)
            .frame(maxWidth: .infinity,
                   maxHeight: .infinity)
            .feedback { source, loop in
                ZStack {
                    source
                        .opacity(0.1)
                    loop
                        .scaleEffect(1.01)
                        .opacity(0.99)
                }
            }
    }
}

#Preview {
    ContentView()
}

Edge

import SwiftUI
import MetalUI

struct ContentView: View {
    
    var content: some View {
        
    }
    
    var body: some View {
        HStack {
            Image(systemName: "globe")
            Text("Hello, World!")
        }
        .font(.system(size: 50, weight: .bold))
        .padding()
        .edge()
    }
}

#Preview {
    ContentView()
}

Pixelate

import SwiftUI
import MetalUI

struct ContentView: View {
    
    var body: some View {
        VStack {
            Text("Hello, World!")
            Text("Hello, World!")
                .pixelate()
            Text("Hello, World!")
                .quickPixelate()
        }
        .font(.largeTitle)
    }
}

#Preview {
    ContentView()
}

Noise

import SwiftUI
import MetalUI

struct ContentView: View {
    
    var body: some View {
        Noise()
    }
}

#Preview {
    ContentView()
}

最近版本更新:(数据更新于 2026-02-13 11:40:33)

主题(topics):

ios17, macos14, metal, swift

heestand-xyz/MetalUI同语言 Metal最近更新仓库

2024-04-28 16:27:31 yangKJ/Harbeth

1970-01-01 00:00:00 twostraws/Inferno

1970-01-01 00:00:00 alexiscn/MTTransitions