diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-07-27 10:05:23 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-07-27 10:05:23 +0200 |
| commit | 5bf66662a9bdd62c5bccab15e607cd95cfb8fcab (patch) | |
| tree | 39a1a4629749056191c05dfd899f931701b7acf3 /srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php | |
| parent | 5afd237bbd22028b85532b8c0b3fcead49a00764 (diff) | |
| download | ft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.tar.gz ft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.tar.bz2 ft_server-5bf66662a9bdd62c5bccab15e607cd95cfb8fcab.zip | |
Removed wordpress and phpmyadmin, my server doesn't handle it well and it brings shame on my famillyHEADmaster
Diffstat (limited to 'srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php')
| -rw-r--r-- | srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php deleted file mode 100644 index ab16276..0000000 --- a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/ImageRenderer.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php -declare(strict_types = 1); - -namespace BaconQrCode\Renderer; - -use BaconQrCode\Encoder\MatrixUtil; -use BaconQrCode\Encoder\QrCode; -use BaconQrCode\Exception\InvalidArgumentException; -use BaconQrCode\Renderer\Image\ImageBackEndInterface; -use BaconQrCode\Renderer\Path\Path; -use BaconQrCode\Renderer\RendererStyle\EyeFill; -use BaconQrCode\Renderer\RendererStyle\RendererStyle; - -final class ImageRenderer implements RendererInterface -{ - /** - * @var RendererStyle - */ - private $rendererStyle; - - /** - * @var ImageBackEndInterface - */ - private $imageBackEnd; - - public function __construct(RendererStyle $rendererStyle, ImageBackEndInterface $imageBackEnd) - { - $this->rendererStyle = $rendererStyle; - $this->imageBackEnd = $imageBackEnd; - } - - /** - * @throws InvalidArgumentException if matrix width doesn't match height - */ - public function render(QrCode $qrCode) : string - { - $size = $this->rendererStyle->getSize(); - $margin = $this->rendererStyle->getMargin(); - $matrix = $qrCode->getMatrix(); - $matrixSize = $matrix->getWidth(); - - if ($matrixSize !== $matrix->getHeight()) { - throw new InvalidArgumentException('Matrix must have the same width and height'); - } - - $totalSize = $matrixSize + ($margin * 2); - $moduleSize = $size / $totalSize; - $fill = $this->rendererStyle->getFill(); - - $this->imageBackEnd->new($size, $fill->getBackgroundColor()); - $this->imageBackEnd->scale((float) $moduleSize); - $this->imageBackEnd->translate((float) $margin, (float) $margin); - - $module = $this->rendererStyle->getModule(); - $moduleMatrix = clone $matrix; - MatrixUtil::removePositionDetectionPatterns($moduleMatrix); - $modulePath = $this->drawEyes($matrixSize, $module->createPath($moduleMatrix)); - - if ($fill->hasGradientFill()) { - $this->imageBackEnd->drawPathWithGradient( - $modulePath, - $fill->getForegroundGradient(), - 0, - 0, - $matrixSize, - $matrixSize - ); - } else { - $this->imageBackEnd->drawPathWithColor($modulePath, $fill->getForegroundColor()); - } - - return $this->imageBackEnd->done(); - } - - private function drawEyes(int $matrixSize, Path $modulePath) : Path - { - $fill = $this->rendererStyle->getFill(); - - $eye = $this->rendererStyle->getEye(); - $externalPath = $eye->getExternalPath(); - $internalPath = $eye->getInternalPath(); - - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getTopLeftEyeFill(), - 3.5, - 3.5, - 0, - $modulePath - ); - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getTopRightEyeFill(), - $matrixSize - 3.5, - 3.5, - 90, - $modulePath - ); - $modulePath = $this->drawEye( - $externalPath, - $internalPath, - $fill->getBottomLeftEyeFill(), - 3.5, - $matrixSize - 3.5, - -90, - $modulePath - ); - - return $modulePath; - } - - private function drawEye( - Path $externalPath, - Path $internalPath, - EyeFill $fill, - float $xTranslation, - float $yTranslation, - int $rotation, - Path $modulePath - ) : Path { - if ($fill->inheritsBothColors()) { - return $modulePath - ->append($externalPath->translate($xTranslation, $yTranslation)) - ->append($internalPath->translate($xTranslation, $yTranslation)); - } - - $this->imageBackEnd->push(); - $this->imageBackEnd->translate($xTranslation, $yTranslation); - - if (0 !== $rotation) { - $this->imageBackEnd->rotate($rotation); - } - - if ($fill->inheritsExternalColor()) { - $modulePath = $modulePath->append($externalPath->translate($xTranslation, $yTranslation)); - } else { - $this->imageBackEnd->drawPathWithColor($externalPath, $fill->getExternalColor()); - } - - if ($fill->inheritsInternalColor()) { - $modulePath = $modulePath->append($internalPath->translate($xTranslation, $yTranslation)); - } else { - $this->imageBackEnd->drawPathWithColor($internalPath, $fill->getInternalColor()); - } - - $this->imageBackEnd->pop(); - - return $modulePath; - } -} |
