Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
8b4ae386a7 | |||
2e7c49e299 |
29
README.md
29
README.md
@ -4,7 +4,26 @@ Spinners for the console.
|
||||
|
||||
## Install
|
||||
|
||||
Install using composer.
|
||||
Recommended is to install using composer. Add the repository to your global
|
||||
`~/.config/composer/config.json` file:
|
||||
|
||||
```
|
||||
{
|
||||
"repositories": [
|
||||
{
|
||||
"type": "composer",
|
||||
"url": "https://dev.noccylabs.info/api/packages/noccy/composer"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Then add the package as a dependency:
|
||||
|
||||
```
|
||||
$ composer require noccylabs/spinner
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
@ -32,3 +51,11 @@ while(true) {
|
||||
usleep(10000);
|
||||
}
|
||||
```
|
||||
|
||||
### Included styles
|
||||
|
||||
Style | Width | Notes
|
||||
---|---|---
|
||||
`BrailleDotStyle` | 1 | A snake chasing its tail, new "docker compose" style
|
||||
`RollingBallStyle` | 1 | A rolling ball, "symfony new" style
|
||||
`SpinnerStyle` | 2 | four-part spinner, 2 characters wide
|
||||
|
@ -19,10 +19,13 @@ $spinner7 = new Spinner(fps:5);
|
||||
$spinner8 = new Spinner(fps:10);
|
||||
$spinner9 = new Spinner(fps:20);
|
||||
|
||||
$spinner10 = new Spinner(fps:10, style:NoccyLabs\Spinner\Style\SpinningBarStyle::class);
|
||||
|
||||
$spinner11 = new Spinner(fps:10, style:NoccyLabs\Spinner\Style\BrailleBounceStyle::class);
|
||||
|
||||
// And blast them out every 10ms!
|
||||
while(true) {
|
||||
echo "\r $spinner1 $spinner2 $spinner3 $spinner4 $spinner5 $spinner6 $spinner7 $spinner8 $spinner9 ";
|
||||
echo "\r $spinner1 $spinner2 $spinner3 $spinner4 $spinner5 $spinner6 $spinner7 $spinner8 $spinner9 $spinner10 $spinner11 ";
|
||||
usleep(10000);
|
||||
}
|
||||
|
||||
|
18
src/Style/BrailleBounceStyle.php
Normal file
18
src/Style/BrailleBounceStyle.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Spinner\Style;
|
||||
|
||||
class BrailleBounceStyle implements StyleInterface
|
||||
{
|
||||
public function getFrames(): array
|
||||
{
|
||||
return [
|
||||
mb_chr(0x2809),
|
||||
mb_chr(0x2812),
|
||||
mb_chr(0x2824),
|
||||
mb_chr(0x28c0),
|
||||
mb_chr(0x2824),
|
||||
mb_chr(0x2812),
|
||||
];
|
||||
}
|
||||
}
|
16
src/Style/SpinningBarStyle.php
Normal file
16
src/Style/SpinningBarStyle.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Spinner\Style;
|
||||
|
||||
class SpinningBarStyle implements StyleInterface
|
||||
{
|
||||
public function getFrames(): array
|
||||
{
|
||||
return [
|
||||
"/",
|
||||
"-",
|
||||
"\\",
|
||||
"|",
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user