Created
February 15, 2024 20:15
-
-
Save lbland94/b1f8834fbe0afd4eedbffac54db2ae9c to your computer and use it in GitHub Desktop.
Basic premise to draw a perfect circle via bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Requires xdotool | |
| # cx and cy are the center coordinates around which the circle will be drawn | |
| # r is the radius of the circle | |
| # time is how long the circle will take to draw | |
| # steps is how many steps the circle will be drawn in | |
| r=400 | |
| cx=$(echo "2560 + 1920 / 2 + 0.2" | bc -l) | |
| cy="578.5" | |
| time=2 | |
| steps=150 | |
| step_time=$(echo "$time / $steps" | bc -l) | |
| PI=$(echo '4 * a(1)' | bc -l) | |
| $(for i in $(seq 0 $steps); do ANG=$(echo "2 * $PI * $i / $steps + ($PI / 2)" | bc -l); X=$(echo "s($ANG) * $r + $cx" | bc -l); Y=$(echo "c($ANG) * $r + $cy" | bc -l); if [ $i -eq 0 ]; then printf "xdotool mousemove $X $Y mousedown 1 "; fi; printf "mousemove $X $Y sleep $step_time "; if [ $i -eq $steps ]; then printf "mouseup 1"; fi; done; echo "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment