1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SixtyNine\Cloud\Command; |
4
|
|
|
|
5
|
|
|
use Imagine\Gd\Image; |
6
|
|
|
use Imagine\Gd\Imagine; |
7
|
|
|
use Imagine\Image\Box; |
8
|
|
|
use Imagine\Image\Color; |
9
|
|
|
use SixtyNine\Cloud\Factory\PlacerFactory; |
10
|
|
|
use SixtyNine\Cloud\Renderer\CloudRenderer; |
11
|
|
|
use Symfony\Component\Console\Command\Command; |
12
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
14
|
|
|
use Symfony\Component\Console\Input\InputOption; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
|
17
|
|
|
class DebugUsherCommand extends Command |
18
|
|
|
{ |
19
|
|
|
protected function configure() |
20
|
|
|
{ |
21
|
|
|
$this |
22
|
|
|
->setName('debug:usher') |
23
|
|
|
->setDescription('Show the path a word placer uses') |
24
|
|
|
->addArgument('placer', InputArgument::REQUIRED, 'The name of the words placer') |
25
|
|
|
->addOption('width', null, InputOption::VALUE_OPTIONAL, 'Width of the image', 800) |
26
|
|
|
->addOption('height', null, InputOption::VALUE_OPTIONAL, 'Height of the image', 600) |
27
|
|
|
->addOption('color', null, InputOption::VALUE_OPTIONAL, 'Color of the path', '#FF0000') |
28
|
|
|
->addOption('background-color', null, InputOption::VALUE_OPTIONAL, 'Background color of the cloud', '#FFFFFF') |
29
|
|
|
->addOption('save-to-file', null, InputOption::VALUE_OPTIONAL, 'If set to a file name, the output will be saved there') |
30
|
|
|
->addOption('format', null, InputOption::VALUE_OPTIONAL, 'Output format (gif, jpeg, png)', 'png') |
31
|
|
|
; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
35
|
|
|
{ |
36
|
|
|
$helper = new CommandsHelper(); |
37
|
|
|
$renderer = new CloudRenderer(); |
38
|
|
|
$placerName = $helper->getPlacer($input->getArgument('placer')); |
39
|
|
|
|
40
|
|
|
$imagine = new Imagine(); |
41
|
|
|
$image = $imagine->create( |
42
|
|
|
new Box( |
43
|
|
|
$input->getOption('width'), |
44
|
|
|
$input->getOption('height') |
45
|
|
|
), |
46
|
|
|
new Color( |
47
|
|
|
$input->getOption('background-color') |
48
|
|
|
) |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
$placer = PlacerFactory::getInstance()->getPlacer( |
52
|
|
|
$placerName, |
53
|
|
|
$input->getOption('width'), |
54
|
|
|
$input->getOption('height') |
55
|
|
|
); |
56
|
|
|
|
57
|
|
|
$renderer->renderUsher($image, $placer, $input->getOption('color')); |
58
|
|
|
|
59
|
|
|
$helper->output($image, $input->getOption('format'), $input->getOption('save-to-file')); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|