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; using namespace metal;
//learning shaders stuff here //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) { [[ stitchable ]] half4 loupe(float2 pos, SwiftUI::Layer layer, float2 size, float2 touch) {
float maxDist = 0.1; float maxDist = 0.1;
float2 uv = pos/size; float2 uv = pos/size;

View File

@@ -43,47 +43,55 @@ struct SettingsView: View {
Section("Shaded") { Section("Shaded") {
TimelineView(.animation) { tl in TimelineView(.animation) { tl in
let time = start.distance(to: tl.date) let time = start.distance(to: tl.date)
// Image(systemName: "figure.walk.circle") // Image(systemName: "figure.walk.circle")
// .font(.system(size: 300)) // .font(.system(size: 300))
// .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) // .frame(width: 200, height: 100)
.padding(.vertical, 20) // .padding(.vertical, 20)
.foregroundStyle(.red) // .foregroundStyle(.red)
.compositingGroup() // .compositingGroup()
.visualEffect { // .visualEffect {
content, // content,
proxy in // proxy in
content.distortionEffect( // content.distortionEffect(
ShaderLibrary.waveFlag( // ShaderLibrary.waveFlag(
.float(time), // .float(time),
.float2(proxy.size) // .float2(proxy.size)
), // ),
maxSampleOffset: CGSize(width: 0, height: 40) // maxSampleOffset: CGSize(width: 0, height: 40)
) // )
} // }
.gesture( // .gesture(
DragGesture(minimumDistance: 0) // DragGesture(minimumDistance: 0)
.onChanged { touch = $0.location} // .onChanged { touch = $0.location}
) // )
} }
} }
Section("Shaded") { Section("Shaded") {
TimelineView(.animation) { tl in TimelineView(.animation) { tl in
let time = start.distance(to: tl.date) let time = start.distance(to: tl.date)
// Image(systemName: "figure.walk.circle") Rectangle()
// .font(.system(size: 300)) .frame(width: 300, height: 200)
// .foregroundStyle(.blue) .colorEffect(
// .colorEffect(ShaderLibrary.rainbow( ShaderLibrary.sinebow(
// .float(time) .float2(300, 200),
// )) .float(time)
)
)
// Image(systemName: "figure.walk.circle")
// .font(.system(size: 300))
// .foregroundStyle(.blue)
// .colorEffect(ShaderLibrary.rainbow(
// .float(time)
// ))
} }
} }
Section("Original") { Section("Original") {
@@ -120,19 +128,17 @@ struct SettingsView: View {
.font(.largeTitle).monospaced() .font(.largeTitle).monospaced()
.foregroundStyle(.blue) .foregroundStyle(.blue)
ZStack { ZStack {
// switch hostsManager.settings.cursorType.cursorShape { if hostsManager.settings.cursorType.cursorShape == .block {
if hostsManager.settings.cursorType.cursorShape == .block { Rectangle()
Rectangle() .frame(width: 20, height: 40)
.frame(width: 20, height: 40) } else if hostsManager.settings.cursorType.cursorShape == .bar {
} else if hostsManager.settings.cursorType.cursorShape == .bar { Rectangle()
Rectangle() .frame(width: 4, height: 40)
.frame(width: 4, height: 40) } else if hostsManager.settings.cursorType.cursorShape == .underline {
} else if hostsManager.settings.cursorType.cursorShape == .underline { Rectangle()
Rectangle() .frame(width: 20, height: 4)
.frame(width: 20, height: 4) .padding(.top, 36)
.padding(.top, 36) }
}
// }
} }
// .padding(.leading, 248) // .padding(.leading, 248)
.id(hostsManager.settings.cursorType.cursorShape) .id(hostsManager.settings.cursorType.cursorShape)