Skip to content

Commit

Permalink
feat: more or less lagging intermediate points
Browse files Browse the repository at this point in the history
  • Loading branch information
sphamba committed Dec 3, 2024
1 parent da1caaf commit d431ca8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ As an example of further configuration, you can tune the smear dynamics to be sn
},
```


> [!WARNING] Fire Hazard
> Feel free to experiment with all the configuration options, but be aware that some combinations may cause your cursor to flicker or even **catch fire**. That can happen with the following settings:
> ```lua
> opts = {
> cursor_color = "#ff8800",
> stiffness = 0.6,
> trailing_stiffness = 0.1,
> trailing_exponent = 5,
> gamma = 1,
> }
> ```
### Transparent background
Drawing the smear over a transparent background works better when using a font that supports legacy computing symbols, therefore setting the following option:
Expand Down
4 changes: 2 additions & 2 deletions lua/smear_cursor/animation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ local function set_stiffnesses(head_stiffness, trailing_stiffness)
end

for i = 1, 4 do
local stiffness = head_stiffness
+ (trailing_stiffness - head_stiffness) * (distances[i] - min_distance) / (max_distance - min_distance)
local x = (distances[i] - min_distance) / (max_distance - min_distance)
local stiffness = head_stiffness + (trailing_stiffness - head_stiffness) * x ^ config.trailing_exponent
stiffnesses[i] = math.min(1, stiffness)
end
end
Expand Down
6 changes: 5 additions & 1 deletion lua/smear_cursor/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ M.stiffness = 0.6
-- 0: no movement, 1: instantaneous
M.trailing_stiffness = 0.25

-- How much the tail slows down when getting close to the head.
-- Controls if middle points are closer to the head or the tail.
-- < 1: closer to the tail, > 1: closer to the head
M.trailing_exponent = 2

-- How much the smear slows down when getting close to the target.
-- 0: no slowdown, more: more slowdown
M.slowdown_exponent = 0

Expand Down

0 comments on commit d431ca8

Please sign in to comment.