-
-
Save WizardOfArc/4219041 to your computer and use it in GitHub Desktop.
A little cutesy command line animation
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
| /** | |
| * Blinky is a little ASCII animation inspired by | |
| * Shane Harter's Progress Display for PHP CLI scripts | |
| * see: https://gist.github.com/4211173 | |
| * this one is written by Azi Crawford forked by Tim Correia forked again by Azi Crawford | |
| * 12/08/2012 -> added ears to blinky | |
| **/ | |
| $blinks_array = array( '<O.O>', '<O.o>', '<O.->', '<O.o>', '<O.O>', '<o.O>', '<-.O>', '<o.O>', '<O.O>', '<o.o>', '<-.->', '<o.o>' ); | |
| define('SCREEN_WIDTH', `tput cols` - 2); | |
| function draw_blink ($counter){ | |
| $screen_width = `tput cols` - 2; | |
| $frame = $counter % 12; | |
| global $blinks_array; | |
| $blink = $blinks_array[$frame]; | |
| echo "\r"; | |
| echo str_pad($blink, $screen_width, ' ', STR_PAD_BOTH); | |
| } | |
| echo str_repeat("\n", 10); | |
| for ($i=0; $i<144; $i++) { | |
| draw_blink($i); | |
| usleep(125000); | |
| } | |
| echo str_repeat("\010", SCREEN_WIDTH); | |
| echo str_pad("<O.O>", SCREEN_WIDTH, ' ', STR_PAD_BOTH) . PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment