by
128 11
0
4
2,931
0
Top 1% !
Popular
Famous
Specified
Popularity: 5490th place
Created
Modified Apr 24, 2013
This snippet is Public
No tags for this snippet yet.
LanguagePHP
LicenseMIT_X11
SourceGithub

A little cutesy command line animation

A little cutesy command line animation: 
blinky.php
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1023/A-little-cutesy-command-line-animation?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
<?php /** * 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 **/ function draw_blink ($counter){ $frame = $counter % 12; switch ($frame) { case 0: echo str_repeat("\010", 50); echo str_pad("O.O", 50, ' ', STR_PAD_LEFT); break; case 1: echo str_repeat("\010", 50); echo str_pad("O.o", 50, ' ', STR_PAD_LEFT); break; case 2: echo str_repeat("\010", 50); echo str_pad("O.-", 50, ' ', STR_PAD_LEFT); break; case 3: echo str_repeat("\010", 50); echo str_pad("O.o", 50, ' ', STR_PAD_LEFT); break; case 4: echo str_repeat("\010", 50); echo str_pad("O.O", 50, ' ', STR_PAD_LEFT); break; case 5: echo str_repeat("\010", 50); echo str_pad("o.O", 50, ' ', STR_PAD_LEFT); break; case 6: echo str_repeat("\010", 50); echo str_pad("-.O", 50, ' ', STR_PAD_LEFT); break; case 7: echo str_repeat("\010", 50); echo str_pad("o.O", 50, ' ', STR_PAD_LEFT); break; case 8: echo str_repeat("\010", 50); echo str_pad("O.O", 50, ' ', STR_PAD_LEFT); break; case 9: echo str_repeat("\010", 50); echo str_pad("o.o", 50, ' ', STR_PAD_LEFT); break; case 10: echo str_repeat("\010", 50); echo str_pad("-.-", 50, ' ', STR_PAD_LEFT); break; case 11: echo str_repeat("\010", 50); echo str_pad("o.o", 50, ' ', STR_PAD_LEFT); break; } } echo str_repeat("\n", 10); for ($i=0; $i<100; $i++) { draw_blink($i); usleep(125000); } echo str_repeat("\010", 50); echo str_repeat(' ', 50) . PHP_EOL;
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus