Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

pipeseroni/weave.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

9 Commits

Repository files navigation

weave.sh

Weaving with simple math in terminal.

It's written intently to be used as a screensaver. To weave, you need to give it an evaluation code as first argument, e.g.

weave.sh '(((x + y) % 2))'

The script draws vertical lines first, then use the supplied code to decide if a horizontal line is weaved over the vertical line. Where x is between 1 and terminal width W (columns) and y is between 1 and terminal height H (rows). If it evaluates as true, meaning the final value == 0, then it does that; otherwise go under the vertical line. There is more examples in sample-screensaver.sh. You can even write a Bash function if it's too complicated as one-liner:

triangle() {
 (((x + y) % 2)) && ((x * H / W >= (y - 1)))
}
export -f triangle
weave.sh 'triangle'

Configuration

The script has no options, it relies on environment variables entirely, the following is the default values:

# Characters and colors for vertical and horizontal lines
char_v='|' char_h='-'
color_v='\e[32;1m' color_h='\e[31;1m'
# Sleep delays
sleep_v=0.01 ${sleep_h=0.01
sleep_end=5

eval_h="1ドル" # Get evaluation code from '1ドル'
eval_h='(((x+y)%2))' # , or set to a default pattern
show_eval_h=no #"yes" to print out evaluation code

For example, if you want to change the characters, you can do

char_v='' char_h='' weave.sh

Screenshots and video

Here is a video of sample-screensaver.sh.

weave.sh '(( $(echo "v=s(($x-1)24a(1)/$W);scale=0;$H-$H(v+1)/2 == $y" | bc -l) ))'

weave.sh '(( $(echo "v=s(($x-1)*2*4*a(1)/$W);scale=0;$H-$H*(v+1)/2 == $y" | bc -l) ))'

weave.sh '(((x % 5 + y % 11) % 2))

weave.sh '(((x % 5 + y % 11) % 2))

Contribution

Feel free to create pull request. Whether make the code better or add some awesome examples to sample-screensaver.sh, they are all welcome.

License

Copyright (c) 2013 Yu-Jie Lin
weave.sh is licensed under the MIT License

AltStyle によって変換されたページ (->オリジナル) /