i am a meower and i forgot what i did
This commit is contained in:
parent
300d20bdee
commit
fe54e9b0c9
9 changed files with 260 additions and 32 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
flake.lock
|
||||
.DS_STORE
|
||||
**/.DS_STORE
|
||||
result
|
||||
result-*
|
||||
|
|
114
files/ghostty/cursor-smear-black.glsl
Normal file
114
files/ghostty/cursor-smear-black.glsl
Normal file
|
@ -0,0 +1,114 @@
|
|||
float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b)
|
||||
{
|
||||
vec2 d = abs(p - xy) - b;
|
||||
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
||||
}
|
||||
|
||||
// Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/
|
||||
// Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching
|
||||
|
||||
float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) {
|
||||
vec2 e = b - a;
|
||||
vec2 w = p - a;
|
||||
vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0);
|
||||
float segd = dot(p - proj, p - proj);
|
||||
d = min(d, segd);
|
||||
|
||||
float c0 = step(0.0, p.y - a.y);
|
||||
float c1 = 1.0 - step(0.0, p.y - b.y);
|
||||
float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x);
|
||||
float allCond = c0 * c1 * c2;
|
||||
float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2);
|
||||
float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond));
|
||||
s *= flip;
|
||||
return d;
|
||||
}
|
||||
|
||||
float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) {
|
||||
float s = 1.0;
|
||||
float d = dot(p - v0, p - v0);
|
||||
|
||||
d = seg(p, v0, v3, s, d);
|
||||
d = seg(p, v1, v0, s, d);
|
||||
d = seg(p, v2, v1, s, d);
|
||||
d = seg(p, v3, v2, s, d);
|
||||
|
||||
return s * sqrt(d);
|
||||
}
|
||||
|
||||
vec2 normalize(vec2 value, float isPosition) {
|
||||
return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y;
|
||||
}
|
||||
|
||||
float antialising(float distance) {
|
||||
return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance);
|
||||
}
|
||||
|
||||
float determineStartVertexFactor(vec2 a, vec2 b) {
|
||||
// Conditions using step
|
||||
float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y
|
||||
float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y
|
||||
|
||||
// If neither condition is met, return 1 (else case)
|
||||
return 1.0 - max(condition1, condition2);
|
||||
}
|
||||
|
||||
vec2 getRectangleCenter(vec4 rectangle) {
|
||||
return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.));
|
||||
}
|
||||
float ease(float x) {
|
||||
return pow(1.0 - x, 3.0);
|
||||
}
|
||||
|
||||
const vec4 TRAIL_COLOR = vec4(0.0, 0.2, 0.5, 0.1);
|
||||
const float DURATION = 0.15; //IN SECONDS
|
||||
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord)
|
||||
{
|
||||
#if !defined(WEB)
|
||||
fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy);
|
||||
#endif
|
||||
// Normalization for fragCoord to a space of -1 to 1;
|
||||
vec2 vu = normalize(fragCoord, 1.);
|
||||
vec2 offsetFactor = vec2(-.5, 0.5);
|
||||
|
||||
// Normalization for cursor position and size;
|
||||
// cursor xy has the postion in a space of -1 to 1;
|
||||
// zw has the width and height
|
||||
vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.));
|
||||
vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.));
|
||||
|
||||
// When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor
|
||||
float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy);
|
||||
float invertedVertexFactor = 1.0 - vertexFactor;
|
||||
|
||||
// Set every vertex of my parellogram
|
||||
vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w);
|
||||
vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y);
|
||||
vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y);
|
||||
vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w);
|
||||
|
||||
float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5);
|
||||
float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3);
|
||||
|
||||
float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0);
|
||||
float easedProgress = ease(progress);
|
||||
// Distance between cursors determine the total length of the parallelogram;
|
||||
vec2 centerCC = getRectangleCenter(currentCursor);
|
||||
vec2 centerCP = getRectangleCenter(previousCursor);
|
||||
float lineLength = distance(centerCC, centerCP);
|
||||
|
||||
vec4 newColor = vec4(fragColor);
|
||||
// Compute fade factor based on distance along the trail
|
||||
float fadeFactor = 1.0 - smoothstep(lineLength, sdfCurrentCursor, easedProgress * lineLength);
|
||||
|
||||
// Apply fading effect to trail color
|
||||
vec4 fadedTrailColor = TRAIL_COLOR * fadeFactor;
|
||||
|
||||
// Blend trail with fade effect
|
||||
newColor = mix(newColor, fadedTrailColor, antialising(sdfTrail));
|
||||
// Draw current cursor
|
||||
newColor = mix(newColor, TRAIL_COLOR, antialising(sdfCurrentCursor));
|
||||
newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.));
|
||||
fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * lineLength));
|
||||
}
|
114
files/ghostty/cursor-smear-blue.glsl
Normal file
114
files/ghostty/cursor-smear-blue.glsl
Normal file
|
@ -0,0 +1,114 @@
|
|||
float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b)
|
||||
{
|
||||
vec2 d = abs(p - xy) - b;
|
||||
return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0);
|
||||
}
|
||||
|
||||
// Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/
|
||||
// Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching
|
||||
|
||||
float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) {
|
||||
vec2 e = b - a;
|
||||
vec2 w = p - a;
|
||||
vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0);
|
||||
float segd = dot(p - proj, p - proj);
|
||||
d = min(d, segd);
|
||||
|
||||
float c0 = step(0.0, p.y - a.y);
|
||||
float c1 = 1.0 - step(0.0, p.y - b.y);
|
||||
float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x);
|
||||
float allCond = c0 * c1 * c2;
|
||||
float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2);
|
||||
float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond));
|
||||
s *= flip;
|
||||
return d;
|
||||
}
|
||||
|
||||
float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) {
|
||||
float s = 1.0;
|
||||
float d = dot(p - v0, p - v0);
|
||||
|
||||
d = seg(p, v0, v3, s, d);
|
||||
d = seg(p, v1, v0, s, d);
|
||||
d = seg(p, v2, v1, s, d);
|
||||
d = seg(p, v3, v2, s, d);
|
||||
|
||||
return s * sqrt(d);
|
||||
}
|
||||
|
||||
vec2 normalize(vec2 value, float isPosition) {
|
||||
return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y;
|
||||
}
|
||||
|
||||
float antialising(float distance) {
|
||||
return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance);
|
||||
}
|
||||
|
||||
float determineStartVertexFactor(vec2 a, vec2 b) {
|
||||
// Conditions using step
|
||||
float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y
|
||||
float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y
|
||||
|
||||
// If neither condition is met, return 1 (else case)
|
||||
return 1.0 - max(condition1, condition2);
|
||||
}
|
||||
|
||||
vec2 getRectangleCenter(vec4 rectangle) {
|
||||
return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.));
|
||||
}
|
||||
float ease(float x) {
|
||||
return pow(1.0 - x, 3.0);
|
||||
}
|
||||
|
||||
const vec4 TRAIL_COLOR = vec4(0.8, 1.0, 1.0, 0.1);
|
||||
const float DURATION = 0.1; //IN SECONDS
|
||||
|
||||
void mainImage(out vec4 fragColor, in vec2 fragCoord)
|
||||
{
|
||||
#if !defined(WEB)
|
||||
fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy);
|
||||
#endif
|
||||
// Normalization for fragCoord to a space of -1 to 1;
|
||||
vec2 vu = normalize(fragCoord, 1.);
|
||||
vec2 offsetFactor = vec2(-.5, 0.5);
|
||||
|
||||
// Normalization for cursor position and size;
|
||||
// cursor xy has the postion in a space of -1 to 1;
|
||||
// zw has the width and height
|
||||
vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.));
|
||||
vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.));
|
||||
|
||||
// When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor
|
||||
float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy);
|
||||
float invertedVertexFactor = 1.0 - vertexFactor;
|
||||
|
||||
// Set every vertex of my parellogram
|
||||
vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w);
|
||||
vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y);
|
||||
vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y);
|
||||
vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w);
|
||||
|
||||
float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5);
|
||||
float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3);
|
||||
|
||||
float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0);
|
||||
float easedProgress = ease(progress);
|
||||
// Distance between cursors determine the total length of the parallelogram;
|
||||
vec2 centerCC = getRectangleCenter(currentCursor);
|
||||
vec2 centerCP = getRectangleCenter(previousCursor);
|
||||
float lineLength = distance(centerCC, centerCP);
|
||||
|
||||
vec4 newColor = vec4(fragColor);
|
||||
// Compute fade factor based on distance along the trail
|
||||
float fadeFactor = 1.0 - smoothstep(lineLength, sdfCurrentCursor, easedProgress * lineLength);
|
||||
|
||||
// Apply fading effect to trail color
|
||||
vec4 fadedTrailColor = TRAIL_COLOR * fadeFactor;
|
||||
|
||||
// Blend trail with fade effect
|
||||
newColor = mix(newColor, fadedTrailColor, antialising(sdfTrail));
|
||||
// Draw current cursor
|
||||
newColor = mix(newColor, TRAIL_COLOR, antialising(sdfCurrentCursor));
|
||||
newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.));
|
||||
fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * lineLength));
|
||||
}
|
|
@ -16,7 +16,14 @@ in
|
|||
imports = mainHomeImports ++ [
|
||||
./macos/sketchybar.nix
|
||||
];
|
||||
programs = {
|
||||
options = {
|
||||
programs.ghostty.shader = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = { };
|
||||
description = "set the ghostty shader, relative to 'files/ghostty'";
|
||||
};
|
||||
};
|
||||
config.programs = {
|
||||
home-manager.enable = true;
|
||||
nix-index.enable = true;
|
||||
|
||||
|
@ -89,5 +96,9 @@ in
|
|||
test -r '/Users/${user.username}/.opam/opam-init/init.fish' && source '/Users/${user.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true
|
||||
'';
|
||||
};
|
||||
|
||||
ghostty.settings.custom-shader = lib.mkIf (
|
||||
cfg.ghostty.shader != null
|
||||
) "${../../files/ghostty}/${cfg.ghostty.shader}";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
|
|
@ -184,17 +184,9 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
binds = {
|
||||
whichKey.enable = true;
|
||||
cheatsheet.enable = true;
|
||||
# discourages bad keyboard habit, e.g. disables arrow keys, explains better binds
|
||||
# https://github.com/m4xshen/hardtime.nvim
|
||||
hardtime-nvim.enable = true;
|
||||
hardtime-nvim.setupOpts = {
|
||||
disable_mouse = false;
|
||||
restriction_mode = "hint"; # default behavior is lenient
|
||||
};
|
||||
};
|
||||
ui = {
|
||||
borders.enable = true;
|
||||
|
@ -206,19 +198,6 @@
|
|||
enable = false;
|
||||
navbuddy.enable = config.vim.ui.breadcrumbs.enable;
|
||||
};
|
||||
smartcolumn = {
|
||||
enable = true;
|
||||
setupOpts.custom_colorcolumn = {
|
||||
# this is a freeform module, it's `buftype = int;` for configuring column position
|
||||
nix = "110";
|
||||
ruby = "120";
|
||||
java = "130";
|
||||
go = [
|
||||
"90"
|
||||
"130"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
notes = {
|
||||
todo-comments.enable = true;
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
git
|
||||
];
|
||||
|
||||
services.tailscale.enable = true;
|
||||
|
||||
# configuration for shared modules.
|
||||
# all custom options in 'shared' for clarity.
|
||||
shared.darwin = {
|
||||
|
|
|
@ -10,7 +10,9 @@ in
|
|||
let
|
||||
# packages to always install
|
||||
all = [
|
||||
ffmpeg
|
||||
(ffmpeg.override {
|
||||
withSvtav1 = true;
|
||||
})
|
||||
ripgrep
|
||||
uv
|
||||
nh
|
||||
|
@ -33,12 +35,26 @@ in
|
|||
};
|
||||
programs = {
|
||||
# sort-lines:start
|
||||
bat.enable = true;
|
||||
# bat.enable = true;
|
||||
btop.enable = true;
|
||||
fd.enable = true;
|
||||
hyfetch.enable = true;
|
||||
# sort-lines:end
|
||||
|
||||
ghostty = {
|
||||
enable = true;
|
||||
shader = "cursor-smear-black.glsl";
|
||||
package = null;
|
||||
settings = {
|
||||
theme = "catppuccin-latte";
|
||||
font-family = "AT Name Mono";
|
||||
adjust-cursor-thickness = 1;
|
||||
minimum-contrast = 1.1;
|
||||
background-opacity = 0.9;
|
||||
background-blur = true;
|
||||
};
|
||||
};
|
||||
|
||||
# zsh is the shell i use
|
||||
zsh = {
|
||||
enable = true;
|
||||
|
|
|
@ -14,12 +14,6 @@ _: {
|
|||
foldenable = true;
|
||||
linebreak = true;
|
||||
};
|
||||
binds = {
|
||||
hardtime-nvim.setupOpts = {
|
||||
restriction_mode = "block";
|
||||
disable_mouse = false;
|
||||
};
|
||||
};
|
||||
git = {
|
||||
gitsigns.setupOpts = {
|
||||
current_line_blame = true;
|
||||
|
|
Loading…
Reference in a new issue