diff --git a/ShhShell/Terminal/CRT.metal b/ShhShell/Terminal/CRT.metal index 33d7e05..11dd3db 100644 --- a/ShhShell/Terminal/CRT.metal +++ b/ShhShell/Terminal/CRT.metal @@ -13,12 +13,19 @@ using namespace metal; float2 uv = pos/size; // scanwave - half3 newCol = 0.75 + 0.5 + 0.5 * sin(time*0.5 + uv.y*10); + half3 scanwave = 0.75 + 0.5 + 0.5 * sin(time*0.5 + uv.y*10); //scanlines - newCol *= 0.5 + 0.5 * sin(uv.y * 1250.0); + half scanline = 0.5 + 0.5 * sin(uv.y * 1250.0); + scanline *= 0.5; + + half3 newColor = scanwave*scanline; + + half alpha = 1 - scanline; + alpha *= 0.75; + // half4 output = half4(layer.sample(pos).xyz*newCol, 1); - half4 output = half4(color.xyz*newCol*0.5, 0.5); + half4 output = half4(color.xyz*newColor*alpha, alpha); return output; } diff --git a/ShhShell/Terminal/ShaderTestingView.swift b/ShhShell/Terminal/ShaderTestingView.swift index b205c8c..751fc4b 100644 --- a/ShhShell/Terminal/ShaderTestingView.swift +++ b/ShhShell/Terminal/ShaderTestingView.swift @@ -8,14 +8,70 @@ import SwiftUI struct ShaderTestingView: View { - var body: some View { + @State private var start = Date.now + + var body: some View { Image(systemName: "figure.walk.circle") .font(.system(size: 300)) .foregroundStyle(.blue) .colorEffect(ShaderLibrary.redify()) - } + Section("Shaded") { + TimelineView(.animation) { tl in + let time = start.distance(to: tl.date) + Image(systemName: "figure.walk.circle") + .font(.system(size: 300)) + .foregroundStyle(.blue) + .distortionEffect( + ShaderLibrary.wave( + .float(time) + ), + maxSampleOffset: .zero + ) + Rectangle() + .frame(width: 200, height: 100) + .padding(.vertical, 20) + .foregroundStyle(.red) + .compositingGroup() + .visualEffect { + content, + proxy in + content.distortionEffect( + ShaderLibrary.waveFlag( + .float(time), + .float2(proxy.size) + ), + maxSampleOffset: CGSize(width: 0, height: 40) + ) + } + } + } + Section("Shaded") { + TimelineView(.animation) { tl in + let time = start.distance(to: tl.date) + Rectangle() + .frame(width: 300, height: 200) + .colorEffect( + ShaderLibrary.sinebow( + .float2(300, 200), + .float(time) + ) + ) + Image(systemName: "figure.walk.circle") + .font(.system(size: 300)) + .foregroundStyle(.blue) + .colorEffect(ShaderLibrary.rainbow( + .float(time) + )) + } + } + Section("Original") { + Image(systemName: "figure.walk.circle") + .font(.system(size: 300)) + .foregroundStyle(.blue) + } + } } #Preview { - ShaderTestingView() + ShaderTestingView() } diff --git a/ShhShell/Views/ContentView.swift b/ShhShell/Views/ContentView.swift index 670c5d2..e6f498f 100644 --- a/ShhShell/Views/ContentView.swift +++ b/ShhShell/Views/ContentView.swift @@ -18,13 +18,6 @@ struct ContentView: View { hostsManager.selectedTheme.background.suiColor.opacity(0.7) .ignoresSafeArea(.all) List { - ForEach(0..<6) { - Color.red.frame(width: 60, height: 60, alignment: .center) - .brightness(Double($0) * 0.2) - .overlay(Text("\(Double($0) * 0.2 * 100, specifier: "%.0f")%"), - alignment: .bottom) - .border(Color.gray) - } SessionsListView( handler: handler, hostsManager: hostsManager, diff --git a/ShhShell/Views/Settings/SettingsView.swift b/ShhShell/Views/Settings/SettingsView.swift index 51f3bdf..4902940 100644 --- a/ShhShell/Views/Settings/SettingsView.swift +++ b/ShhShell/Views/Settings/SettingsView.swift @@ -14,8 +14,6 @@ struct SettingsView: View { @State private var blinkCursor: Int = 0 @State var blinkTimer: Timer? - @State private var start = Date.now - @State private var touch = CGPoint.zero func startBlinkingIfNeeded() { if hostsManager.settings.cursorType.blink { @@ -40,66 +38,6 @@ struct SettingsView: View { hostsManager.selectedTheme.background.suiColor.opacity(0.7) .ignoresSafeArea(.all) List { - Section("Shaded") { - TimelineView(.animation) { tl in - let time = start.distance(to: tl.date) -// Image(systemName: "figure.walk.circle") -// .font(.system(size: 300)) -// .foregroundStyle(.blue) -// .distortionEffect( -// ShaderLibrary.wave( -// .float(time) -// ), -// maxSampleOffset: .zero -// ) -// Rectangle() -// .frame(width: 200, height: 100) -// .padding(.vertical, 20) -// .foregroundStyle(.red) -// .compositingGroup() -// .visualEffect { -// content, -// proxy in -// content.distortionEffect( -// ShaderLibrary.waveFlag( -// .float(time), -// .float2(proxy.size) -// ), -// maxSampleOffset: CGSize(width: 0, height: 40) -// ) -// } -// .gesture( -// DragGesture(minimumDistance: 0) -// .onChanged { touch = $0.location} -// ) - } - } - - Section("Shaded") { - TimelineView(.animation) { tl in - let time = start.distance(to: tl.date) - Rectangle() - .frame(width: 300, height: 200) - .colorEffect( - ShaderLibrary.sinebow( - .float2(300, 200), - .float(time) - ) - ) -// Image(systemName: "figure.walk.circle") -// .font(.system(size: 300)) -// .foregroundStyle(.blue) -// .colorEffect(ShaderLibrary.rainbow( -// .float(time) -// )) - } - } - Section("Original") { - Image(systemName: "figure.walk.circle") - .font(.system(size: 300)) - .foregroundStyle(.blue) - } - Section("Terminal") { VStack(alignment: .leading) { HStack { diff --git a/ShhShell/Views/Terminal/ShellView.swift b/ShhShell/Views/Terminal/ShellView.swift index 248c0bf..296b33f 100644 --- a/ShhShell/Views/Terminal/ShellView.swift +++ b/ShhShell/Views/Terminal/ShellView.swift @@ -36,9 +36,12 @@ struct ShellView: View { // maxSampleOffset: .zero // ) // } +// .blendMode(.screen) .overlay { if hostsManager.settings.filter == .crt { CRTView() + .opacity(0.75) + .allowsHitTesting(false) } }