示例#1
0
 public function generateImagesFromLetter(ImageStrategy $strategy, string $letter) : ImageCollection
 {
     $palette = $this->colorsService->getRandomPalette();
     $bgColor = $palette->getBackground();
     $textColor = $palette->getForeground();
     $size = max($strategy->getSizes());
     $fontSize = (int) $size * 0.8;
     $img = $this->imageManager->canvas($size, $size, $bgColor->getHexCode());
     $char = strtoupper($strategy->getLetter());
     $fontPath = $this->fontPath;
     $img->text($char, (int) $size / 2, (int) $size / 2, function (Font $font) use($fontSize, $textColor, $fontPath) {
         $font->file($fontPath);
         $font->size($fontSize);
         $font->color($textColor->getHexCode());
         $font->align('center');
         $font->valign('center');
     });
     return $this->generateImagesFromSource($strategy, $img);
 }
示例#2
0
 public function run(ServerRequestInterface $request, ResponseBuilder $responseBuilder) : ResponseInterface
 {
     return $responseBuilder->setJson(['palettes' => array_map(function (Palette $palette) {
         return $palette->toJSON();
     }, $this->colorsService->getPalettes())])->setStatusSuccess()->build();
 }
 public function __invoke() : array
 {
     return ['config' => ['palettes' => array_map(function (Palette $palette) {
         return $palette->toJSON();
     }, $this->colorService->getPalettes())]];
 }