[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

two visualizers

Kasper (Oct 2, 2025, 11:46 PM +0200) 719de215 9588da71

+54 -7
+54 -7
src/lib/visualizer/Visualizer.svelte
··· 13 13 const canvas_id = 'visualizer' 14 14 let toy: ShaderToyLite | undefined 15 15 16 - onMount(() => { 17 - const a = ` 16 + const shaders = { 17 + 'Color Warp by yozic': ` 18 18 #define WARP true 19 19 #define BALLS 10. 20 20 #define CONTRAST 3 ··· 47 47 } 48 48 fragColor.xyz = pow(fragColor.xyz, vec3(CONTRAST)); 49 49 } 50 - ` 50 + `, 51 + 'Bars by yozic': ` 52 + #define orbs 20. 53 + #define PI 3.14159265359 54 + #define zoom 24.950 55 + #define div 10.000 56 + #define div2 10.000 57 + #define radius 8.159 58 + #define orbSize 0.682 59 + #define colorShift 12.710 60 + #define contrast 0.902 61 + 62 + // Helper function to get normalized UV coordinates 63 + vec2 k_uv() { 64 + vec2 uv = 2. * gl_FragCoord.xy/iResolution.xy - 1.; 65 + uv.x *= iResolution.x / iResolution.y; 66 + return uv; 67 + } 68 + 69 + // Helper function to create orb effect 70 + vec4 k_orb(vec2 uv, float size, vec2 position, vec3 color, float contrast_val) { 71 + float d = length(uv - position); 72 + float intensity = size / (d + 0.001); 73 + intensity = pow(intensity, contrast_val); 74 + return vec4(color * intensity, 1.0); 75 + } 76 + 77 + void mainImage (out vec4 fragColor, in vec2 fragCoord) { 78 + vec2 uv = k_uv(); 79 + uv *= zoom; 80 + fragColor = vec4(0.); 81 + 82 + for (float i = 0.; i < orbs; i++) { 83 + uv.y -= cos((i+1.)*uv.y/div - iStream); 84 + uv.x += cos((i+1.)*uv.y/div2 - iStream/1.5); 85 + float t = i * PI / orbs; 86 + float x = radius * tan(t + iStream/2.); 87 + float y = radius * cos(t - iStream/2.2) * sin(t-iStream/3.); 88 + vec2 position = vec2(x, y); 89 + vec3 color = cos(vec3(-2, 0, -1) * PI * 2. / 3. + PI * (i / colorShift)) * 0.5 + 0.5; 90 + fragColor += k_orb(uv, iVolume * orbSize, position, color, contrast); 91 + } 92 + } 93 + `, 94 + } 95 + 96 + onMount(() => { 97 + const a = shaders['Bars by yozic'] 51 98 const image = ` 52 99 void mainImage( out vec4 fragColor, in vec2 fragCoord ) { 53 - vec2 uv = fragCoord.xy / iResolution.xy; 54 - vec4 col = texture(iChannel0, uv); 55 - fragColor = vec4(col.rgb, 1.); 100 + vec2 uv = fragCoord.xy / iResolution.xy; 101 + vec4 col = texture(iChannel0, uv); 102 + fragColor = vec4(col.rgb, 1.); 56 103 } 57 - ` 104 + ` 58 105 toy = new ShaderToyLite(canvas_id) 59 106 toy.setCommon('') 60 107 toy.setBufferA({ source: a })