diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-09 10:55:03 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-09 13:09:38 +0100 |
| commit | 04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa (patch) | |
| tree | 5c691241355c943a3c68ddb06b8cf8c60aa11319 /srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle | |
| parent | 7e0d85db834d6351ed85d01e5126ac31dc510b86 (diff) | |
| download | ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.gz ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.bz2 ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.zip | |
phpmyadmin working
Diffstat (limited to 'srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle')
5 files changed, 400 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/EyeFill.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/EyeFill.php new file mode 100644 index 0000000..46abc22 --- /dev/null +++ b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/EyeFill.php @@ -0,0 +1,74 @@ +<?php +declare(strict_types = 1); + +namespace BaconQrCode\Renderer\RendererStyle; + +use BaconQrCode\Exception\RuntimeException; +use BaconQrCode\Renderer\Color\ColorInterface; + +final class EyeFill +{ + /** + * @var ColorInterface|null + */ + private $externalColor; + + /** + * @var ColorInterface|null + */ + private $internalColor; + + /** + * @var self|null + */ + private static $inherit; + + public function __construct(?ColorInterface $externalColor, ?ColorInterface $internalColor) + { + $this->externalColor = $externalColor; + $this->internalColor = $internalColor; + } + + public static function uniform(ColorInterface $color) : self + { + return new self($color, $color); + } + + public static function inherit() : self + { + return self::$inherit ?: self::$inherit = new self(null, null); + } + + public function inheritsBothColors() : bool + { + return null === $this->externalColor && null === $this->internalColor; + } + + public function inheritsExternalColor() : bool + { + return null === $this->externalColor; + } + + public function inheritsInternalColor() : bool + { + return null === $this->internalColor; + } + + public function getExternalColor() : ColorInterface + { + if (null === $this->externalColor) { + throw new RuntimeException('External eye color inherits foreground color'); + } + + return $this->externalColor; + } + + public function getInternalColor() : ColorInterface + { + if (null === $this->internalColor) { + throw new RuntimeException('Internal eye color inherits foreground color'); + } + + return $this->internalColor; + } +} diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php new file mode 100644 index 0000000..d54268e --- /dev/null +++ b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Fill.php @@ -0,0 +1,168 @@ +<?php +declare(strict_types = 1); + +namespace BaconQrCode\Renderer\RendererStyle; + +use BaconQrCode\Exception\RuntimeException; +use BaconQrCode\Renderer\Color\ColorInterface; +use BaconQrCode\Renderer\Color\Gray; + +final class Fill +{ + /** + * @var ColorInterface + */ + private $backgroundColor; + + /** + * @var ColorInterface|null + */ + private $foregroundColor; + + /** + * @var Gradient|null + */ + private $foregroundGradient; + + /** + * @var EyeFill + */ + private $topLeftEyeFill; + + /** + * @var EyeFill + */ + private $topRightEyeFill; + + /** + * @var EyeFill + */ + private $bottomLeftEyeFill; + + /** + * @var self|null + */ + private static $default; + + private function __construct( + ColorInterface $backgroundColor, + ?ColorInterface $foregroundColor, + ?Gradient $foregroundGradient, + EyeFill $topLeftEyeFill, + EyeFill $topRightEyeFill, + EyeFill $bottomLeftEyeFill + ) { + $this->backgroundColor = $backgroundColor; + $this->foregroundColor = $foregroundColor; + $this->foregroundGradient = $foregroundGradient; + $this->topLeftEyeFill = $topLeftEyeFill; + $this->topRightEyeFill = $topRightEyeFill; + $this->bottomLeftEyeFill = $bottomLeftEyeFill; + } + + public static function default() : self + { + return self::$default ?: self::$default = self::uniformColor(new Gray(100), new Gray(0)); + } + + public static function withForegroundColor( + ColorInterface $backgroundColor, + ColorInterface $foregroundColor, + EyeFill $topLeftEyeFill, + EyeFill $topRightEyeFill, + EyeFill $bottomLeftEyeFill + ) : self { + return new self( + $backgroundColor, + $foregroundColor, + null, + $topLeftEyeFill, + $topRightEyeFill, + $bottomLeftEyeFill + ); + } + + public static function withForegroundGradient( + ColorInterface $backgroundColor, + Gradient $foregroundGradient, + EyeFill $topLeftEyeFill, + EyeFill $topRightEyeFill, + EyeFill $bottomLeftEyeFill + ) : self { + return new self( + $backgroundColor, + null, + $foregroundGradient, + $topLeftEyeFill, + $topRightEyeFill, + $bottomLeftEyeFill + ); + } + + public static function uniformColor(ColorInterface $backgroundColor, ColorInterface $foregroundColor) : self + { + return new self( + $backgroundColor, + $foregroundColor, + null, + EyeFill::inherit(), + EyeFill::inherit(), + EyeFill::inherit() + ); + } + + public static function uniformGradient(ColorInterface $backgroundColor, Gradient $foregroundGradient) : self + { + return new self( + $backgroundColor, + null, + $foregroundGradient, + EyeFill::inherit(), + EyeFill::inherit(), + EyeFill::inherit() + ); + } + + public function hasGradientFill() : bool + { + return null !== $this->foregroundGradient; + } + + public function getBackgroundColor() : ColorInterface + { + return $this->backgroundColor; + } + + public function getForegroundColor() : ColorInterface + { + if (null === $this->foregroundColor) { + throw new RuntimeException('Fill uses a gradient, thus no foreground color is available'); + } + + return $this->foregroundColor; + } + + public function getForegroundGradient() : Gradient + { + if (null === $this->foregroundGradient) { + throw new RuntimeException('Fill uses a single color, thus no foreground gradient is available'); + } + + return $this->foregroundGradient; + } + + public function getTopLeftEyeFill() : EyeFill + { + return $this->topLeftEyeFill; + } + + public function getTopRightEyeFill() : EyeFill + { + return $this->topRightEyeFill; + } + + public function getBottomLeftEyeFill() : EyeFill + { + return $this->bottomLeftEyeFill; + } +} diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php new file mode 100644 index 0000000..3813dfd --- /dev/null +++ b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/Gradient.php @@ -0,0 +1,46 @@ +<?php +declare(strict_types = 1); + +namespace BaconQrCode\Renderer\RendererStyle; + +use BaconQrCode\Renderer\Color\ColorInterface; + +final class Gradient +{ + /** + * @var ColorInterface + */ + private $startColor; + + /** + * @var ColorInterface + */ + private $endColor; + + /** + * @var GradientType + */ + private $type; + + public function __construct(ColorInterface $startColor, ColorInterface $endColor, GradientType $type) + { + $this->startColor = $startColor; + $this->endColor = $endColor; + $this->type = $type; + } + + public function getStartColor() : ColorInterface + { + return $this->startColor; + } + + public function getEndColor() : ColorInterface + { + return $this->endColor; + } + + public function getType() : GradientType + { + return $this->type; + } +} diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php new file mode 100644 index 0000000..c1ca754 --- /dev/null +++ b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/GradientType.php @@ -0,0 +1,22 @@ +<?php +declare(strict_types = 1); + +namespace BaconQrCode\Renderer\RendererStyle; + +use DASPRiD\Enum\AbstractEnum; + +/** + * @method static self VERTICAL() + * @method static self HORIZONTAL() + * @method static self DIAGONAL() + * @method static self INVERSE_DIAGONAL() + * @method static self RADIAL() + */ +final class GradientType extends AbstractEnum +{ + protected const VERTICAL = null; + protected const HORIZONTAL = null; + protected const DIAGONAL = null; + protected const INVERSE_DIAGONAL = null; + protected const RADIAL = null; +} diff --git a/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/RendererStyle.php b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/RendererStyle.php new file mode 100644 index 0000000..e03e099 --- /dev/null +++ b/srcs/phpmyadmin/vendor/bacon/bacon-qr-code/src/Renderer/RendererStyle/RendererStyle.php @@ -0,0 +1,90 @@ +<?php +declare(strict_types = 1); + +namespace BaconQrCode\Renderer\RendererStyle; + +use BaconQrCode\Renderer\Eye\EyeInterface; +use BaconQrCode\Renderer\Eye\ModuleEye; +use BaconQrCode\Renderer\Module\ModuleInterface; +use BaconQrCode\Renderer\Module\SquareModule; + +final class RendererStyle +{ + /** + * @var int + */ + private $size; + + /** + * @var int + */ + private $margin; + + /** + * @var ModuleInterface + */ + private $module; + + /** + * @var EyeInterface|null + */ + private $eye; + + /** + * @var Fill + */ + private $fill; + + public function __construct( + int $size, + int $margin = 4, + ?ModuleInterface $module = null, + ?EyeInterface $eye = null, + ?Fill $fill = null + ) { + $this->margin = $margin; + $this->size = $size; + $this->module = $module ?: SquareModule::instance(); + $this->eye = $eye ?: new ModuleEye($this->module); + $this->fill = $fill ?: Fill::default(); + } + + public function withSize(int $size) : self + { + $style = clone $this; + $style->size = $size; + return $style; + } + + public function withMargin(int $margin) : self + { + $style = clone $this; + $style->margin = $margin; + return $style; + } + + public function getSize() : int + { + return $this->size; + } + + public function getMargin() : int + { + return $this->margin; + } + + public function getModule() : ModuleInterface + { + return $this->module; + } + + public function getEye() : EyeInterface + { + return $this->eye; + } + + public function getFill() : Fill + { + return $this->fill; + } +} |
