mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
more shaders
This commit is contained in:
@@ -6,9 +6,25 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
#include <SwiftUI/SwiftUI_Metal.h>
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
|
|
||||||
//learning shaders stuff here
|
//learning shaders stuff here
|
||||||
|
[[ stitchable ]] half4 loupe(float2 pos, SwiftUI::Layer layer, float2 size, float2 touch) {
|
||||||
|
float maxDist = 0.1;
|
||||||
|
float2 uv = pos/size;
|
||||||
|
float2 center = touch/size;
|
||||||
|
float2 delta = uv-center;
|
||||||
|
float aspectRatio = size.x/size.y;
|
||||||
|
float dist = (delta.x * delta.x) + (delta.y * delta.y) / aspectRatio;
|
||||||
|
float totalZoom = 1;
|
||||||
|
if(dist < maxDist) {
|
||||||
|
totalZoom /= 2;
|
||||||
|
}
|
||||||
|
float2 newPos = delta * totalZoom + center;
|
||||||
|
return layer.sample(newPos*size);
|
||||||
|
}
|
||||||
|
|
||||||
[[ stitchable ]] float2 waveFlag(float2 pos, float time, float2 size) {
|
[[ stitchable ]] float2 waveFlag(float2 pos, float time, float2 size) {
|
||||||
float2 distance = pos/size;
|
float2 distance = pos/size;
|
||||||
pos.y += sin(time*5 + pos.x/20) * 5 * distance.x;
|
pos.y += sin(time*5 + pos.x/20) * 5 * distance.x;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ struct SettingsView: View {
|
|||||||
@State private var blinkCursor: Int = 0
|
@State private var blinkCursor: Int = 0
|
||||||
@State var blinkTimer: Timer?
|
@State var blinkTimer: Timer?
|
||||||
@State private var start = Date.now
|
@State private var start = Date.now
|
||||||
|
@State private var touch = CGPoint.zero
|
||||||
|
|
||||||
func startBlinkingIfNeeded() {
|
func startBlinkingIfNeeded() {
|
||||||
if hostsManager.settings.cursorType.blink {
|
if hostsManager.settings.cursorType.blink {
|
||||||
@@ -42,19 +43,20 @@ 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
|
||||||
// )
|
// )
|
||||||
Image(systemName: "square.and.arrow.up")
|
Rectangle()
|
||||||
.font(.system(size: 300))
|
.frame(width: 200, height: 100)
|
||||||
|
.padding(.vertical, 20)
|
||||||
.foregroundStyle(.red)
|
.foregroundStyle(.red)
|
||||||
.drawingGroup()
|
.compositingGroup()
|
||||||
.visualEffect {
|
.visualEffect {
|
||||||
content,
|
content,
|
||||||
proxy in
|
proxy in
|
||||||
@@ -63,22 +65,25 @@ struct SettingsView: View {
|
|||||||
.float(time),
|
.float(time),
|
||||||
.float2(proxy.size)
|
.float2(proxy.size)
|
||||||
),
|
),
|
||||||
maxSampleOffset: .zero
|
maxSampleOffset: CGSize(width: 0, height: 40)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.border(.red)
|
.gesture(
|
||||||
|
DragGesture(minimumDistance: 0)
|
||||||
|
.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")
|
// Image(systemName: "figure.walk.circle")
|
||||||
// .font(.system(size: 300))
|
// .font(.system(size: 300))
|
||||||
// .foregroundStyle(.blue)
|
// .foregroundStyle(.blue)
|
||||||
// .colorEffect(ShaderLibrary.rainbow(
|
// .colorEffect(ShaderLibrary.rainbow(
|
||||||
// .float(time)
|
// .float(time)
|
||||||
// ))
|
// ))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Section("Original") {
|
Section("Original") {
|
||||||
@@ -102,7 +107,7 @@ struct SettingsView: View {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Section("Cursor") {
|
Section("Cursor") {
|
||||||
HStack(spacing: 20) {
|
HStack(spacing: 20) {
|
||||||
Text("neon443")
|
Text("neon443")
|
||||||
@@ -128,7 +133,7 @@ struct SettingsView: View {
|
|||||||
.padding(.top, 36)
|
.padding(.top, 36)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// .padding(.leading, 248)
|
// .padding(.leading, 248)
|
||||||
.onChange(of: hostsManager.settings.cursorType.blink) { _ in
|
.onChange(of: hostsManager.settings.cursorType.blink) { _ in
|
||||||
startBlinkingIfNeeded()
|
startBlinkingIfNeeded()
|
||||||
}
|
}
|
||||||
@@ -215,7 +220,7 @@ struct SettingsView: View {
|
|||||||
hostsManager.saveSettings()
|
hostsManager.saveSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
|
|||||||
Reference in New Issue
Block a user