FelixKratz / JankyBorders

A lightweight window border system for macOS
GNU General Public License v3.0
1k stars 18 forks source link

feat: Add gradient borders #22

Closed mizlan closed 9 months ago

mizlan commented 9 months ago

Very initial, incomplete, hardcoded HACK as of right now.

Creates a gradient that is clipped to the stroke path as described in the SO thread in #19.

I also noticed frame dropping with Yabai resizing (i.e., it would only have maybe 3 intermediate frames that animate in a choppy manner) (fixed by restarting Yabai) which may or may not be related to this.

mizlan commented 9 months ago
FelixKratz commented 9 months ago

I was thinking in terms of configuration syntax it would be sufficient to have something like this for now where we only allow diagonal gradients but can easily extend support to further gradient configurations:

borders active_color=gradient(top_right=<color_hex>,bottom_left=<color_hex>)
borders active_color=gradient(top_left=<color_hex>,bottom_right=<color_hex>)

which would of course also work for the inactive_color.

In the future, further special colors could be supported with this system as well, i.e. active_color=stripes(...) etc.

For the moment the sscanf method is sufficient, it can easily be extended to support even this more complex configuration syntax.

mizlan commented 9 months ago

@FelixKratz Can you explain why this is? https://github.com/FelixKratz/JankyBorders/blob/09ec9196570fe9e25ce788bfbcc3399d3c1cee78/src/border.c#L118-L120

Currently style=square gradient renders twice as thick as it should, and I suspect it has to do with this

mizlan commented 9 months ago

I will probably change the type/field names of the new stuff I introduced, if you have suggestions let me know.

FelixKratz commented 9 months ago

I have made a cleanup pass through the code, fixed some memory leaks, changed some some things around, implemented the directionality and fixed the double wide square gradient borders. Once you sign off on those changes I will merge.

mizlan commented 9 months ago

Looks great! Thanks for doing all that.

One thing: the current syntax is not nice for adding arbitrary number of gradient color "stops"—not sure if you wanted to think more about that (e.g., red one corner -> green in the middle -> blue other corner) or if the current approach is fine.

FelixKratz commented 9 months ago

Thanks!