-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconverter.php
More file actions
30 lines (24 loc) · 770 Bytes
/
Copy pathconverter.php
File metadata and controls
30 lines (24 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Macocci7\BashColorizer\Colorizer;
use Macocci7\BashColorizer\Converter;
// hex to rgb
$hex = '#abcdef';
$rgb = Converter::decimal($hex);
echo sprintf(
"%s => [%s, %s, %s]\n",
Colorizer::foreground($hex)->encode($hex),
Colorizer::foreground('red')->encode($rgb[0]),
Colorizer::foreground('green')->encode($rgb[1]),
Colorizer::foreground('blue')->encode($rgb[2]),
);
// decimal to rgb
$rgb = [254, 220, 186];
$hex = Converter::hex($rgb);
echo sprintf(
"[%s, %s, %s] => %s\n",
Colorizer::foreground('red')->encode($rgb[0]),
Colorizer::foreground('green')->encode($rgb[1]),
Colorizer::foreground('blue')->encode($rgb[2]),
Colorizer::foreground($hex)->encode($hex),
);