sinebow yay

This commit is contained in:
neon443
2025-08-25 19:22:53 +01:00
parent 38ce138cea
commit 99de1e12ef
2 changed files with 73 additions and 48 deletions

View File

@@ -10,6 +10,25 @@
using namespace metal;
//learning shaders stuff here
[[ stitchable ]] half4 sinebow(float2 pos, half4 color, float2 size, float time) {
float2 uv = (pos/size.x) * 2 - 1;
uv.y += 0.15;
float wave = sin(uv.x + time);
wave *= wave * 25;
float luma = abs(1 / (100 * uv.y + wave));
half3 waveColor = half3(0);
for (float i = 0; i < 10; i++) {
half3 rainbow = half3(
sin(0.3 + time) * 0.5 + 0.5,
sin(0.3 + 2 + sin(time * 0.3)) * 0.5 + 0.5,
sin(0.3 + 4 + time) * 0.5 + 0.5
);
waveColor += rainbow * luma;
}
return half4(waveColor, 1);
}
[[ stitchable ]] half4 loupe(float2 pos, SwiftUI::Layer layer, float2 size, float2 touch) {
float maxDist = 0.1;
float2 uv = pos/size;

View File

@@ -43,47 +43,55 @@ struct SettingsView: View {
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}
)
// 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)
// Image(systemName: "figure.walk.circle")
// .font(.system(size: 300))
// .foregroundStyle(.blue)
// .colorEffect(ShaderLibrary.rainbow(
// .float(time)
// ))
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") {
@@ -120,19 +128,17 @@ struct SettingsView: View {
.font(.largeTitle).monospaced()
.foregroundStyle(.blue)
ZStack {
// switch hostsManager.settings.cursorType.cursorShape {
if hostsManager.settings.cursorType.cursorShape == .block {
Rectangle()
.frame(width: 20, height: 40)
} else if hostsManager.settings.cursorType.cursorShape == .bar {
Rectangle()
.frame(width: 4, height: 40)
} else if hostsManager.settings.cursorType.cursorShape == .underline {
Rectangle()
.frame(width: 20, height: 4)
.padding(.top, 36)
}
// }
if hostsManager.settings.cursorType.cursorShape == .block {
Rectangle()
.frame(width: 20, height: 40)
} else if hostsManager.settings.cursorType.cursorShape == .bar {
Rectangle()
.frame(width: 4, height: 40)
} else if hostsManager.settings.cursorType.cursorShape == .underline {
Rectangle()
.frame(width: 20, height: 4)
.padding(.top, 36)
}
}
// .padding(.leading, 248)
.id(hostsManager.settings.cursorType.cursorShape)