implemented shader testing view (shaderplayground)

This commit is contained in:
neon443
2025-08-28 21:00:49 +01:00
parent cd822e1efc
commit 18046d1208
3 changed files with 72 additions and 55 deletions

View File

@@ -47,7 +47,7 @@ class HostsManager: ObservableObject, @unchecked Sendable {
loadFonts() loadFonts()
loadSnippets() loadSnippets()
loadHistory() loadHistory()
// self.shownOnboarding = UserDefaults.standard.bool(forKey: "shownOnboarding") self.shownOnboarding = UserDefaults.standard.bool(forKey: "shownOnboarding")
} }
func setOnboarding(to newValue: Bool) { func setOnboarding(to newValue: Bool) {

View File

@@ -11,24 +11,37 @@ struct ShaderTestingView: View {
@State private var start = Date.now @State private var start = Date.now
var body: some View { var body: some View {
GeometryReader { geo in
TimelineView(.animation) { tl in
ZStack {
let time = start.distance(to: tl.date)
VStack {
HStack {
Image(systemName: "figure.walk.circle") Image(systemName: "figure.walk.circle")
.font(.system(size: 300)) .resizable().scaledToFit()
.foregroundStyle(.blue)
Image(systemName: "arrow.right")
.foregroundStyle(.gray)
.frame(width: 25, height: 25)
Image(systemName: "figure.walk.circle")
.resizable().scaledToFit()
.foregroundStyle(.blue) .foregroundStyle(.blue)
.colorEffect(ShaderLibrary.redify()) .colorEffect(ShaderLibrary.redify())
Section("Shaded") { }
TimelineView(.animation) { tl in
let time = start.distance(to: tl.date)
Image(systemName: "figure.walk.circle") Image(systemName: "figure.walk.circle")
.font(.system(size: 300)) .resizable().scaledToFit()
.foregroundStyle(.blue)
.colorEffect(ShaderLibrary.rainbow(.float(time)))
Image(systemName: "figure.walk.circle")
.resizable().scaledToFit()
.foregroundStyle(.blue) .foregroundStyle(.blue)
.distortionEffect( .distortionEffect(
ShaderLibrary.wave( ShaderLibrary.wave(.float(time)),
.float(time)
),
maxSampleOffset: .zero maxSampleOffset: .zero
) )
Rectangle() Rectangle()
.frame(width: 200, height: 100)
.padding(.vertical, 20) .padding(.vertical, 20)
.foregroundStyle(.red) .foregroundStyle(.red)
.compositingGroup() .compositingGroup()
@@ -36,38 +49,34 @@ struct ShaderTestingView: View {
content, content,
proxy in proxy in
content.distortionEffect( content.distortionEffect(
ShaderLibrary.waveFlag( ShaderLibrary.waveFlag(.float(time), .float2(proxy.size)),
.float(time),
.float2(proxy.size)
),
maxSampleOffset: CGSize(width: 0, height: 40) maxSampleOffset: CGSize(width: 0, height: 40)
) )
} }
}
}
Section("Shaded") {
TimelineView(.animation) { tl in
let time = start.distance(to: tl.date)
Rectangle() Rectangle()
.frame(width: 300, height: 200)
.colorEffect( .colorEffect(
ShaderLibrary.sinebow( ShaderLibrary.sinebow(.float2(300, 200), .float(time))
.float2(300, 200), )
}
.brightness(0.2)
Rectangle()
.foregroundStyle(.black.opacity(1))
.visualEffect { content, proxy in
content
.colorEffect(
ShaderLibrary.crt(
.float2(proxy.size),
.float(time) .float(time)
) )
) )
Image(systemName: "figure.walk.circle") }
.font(.system(size: 300)) .opacity(0.75)
.foregroundStyle(.blue) .blendMode(.overlay)
.colorEffect(ShaderLibrary.rainbow( .allowsHitTesting(false)
.float(time)
))
} }
} }
Section("Original") {
Image(systemName: "figure.walk.circle")
.font(.system(size: 300))
.foregroundStyle(.blue)
} }
} }
} }

View File

@@ -50,6 +50,14 @@ struct AboutView: View {
.shadow(radius: 2) .shadow(radius: 2)
} }
} }
NavigationLink {
ShaderTestingView()
} label: {
Text("Shader Playground")
.bold()
Text("This is a collection of all the shaders I made while learning!")
}
} }
.transition(.scale) .transition(.scale)
.frame(maxWidth: .infinity) .frame(maxWidth: .infinity)