update to forgejo 10.0.0
This commit is contained in:
parent
d30934945c
commit
cc7fe5181b
57 changed files with 3854 additions and 18 deletions
7
color-convert/index.php
Normal file
7
color-convert/index.php
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
for ($i = 0; $i < 361; $i++) {
|
||||
$c = 'hsla('.$i.',96%,61%,1)';
|
||||
|
||||
echo "<button style='background: ".$c."'>".$c."</button>";
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
23
color-convert/update
Executable file
23
color-convert/update
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
for i in theme-forgejo-auto.css theme-forgejo-dark.css theme-forgejo-light.css; do
|
||||
rm "$i"
|
||||
wget -q -O "$i" "https://gitnet.fr/assets/css/$i?v=$(date +'%Y-%m-%dT%H:%m:%S')"
|
||||
|
||||
./replacer $i blue '#3ca8fb'
|
||||
./replacer $i pink '#fb3bbe'
|
||||
./replacer $i green '#15803d'
|
||||
./replacer $i crimson '#ff6c6b'
|
||||
./replacer $i yellow '#e1da0e'
|
||||
done
|
||||
|
||||
for i in *dark*; do
|
||||
echo ".secondary-nav { background: #0d1116 !important; }" >> $i
|
||||
done
|
||||
|
||||
for i in theme-forgejo-auto.css theme-forgejo-dark.css theme-forgejo-light.css; do
|
||||
for c in blue pink green crimson yellow; do
|
||||
f="$(echo -n "$i" | sed 's/.css/-'"$c"'.css/')"
|
||||
echo wget -O $f \""https://assets.gitnet.fr/$f?v=$(date +'%Y-%m-%dT%H:%m:%S')"\"
|
||||
done
|
||||
done
|
||||
12
color-convert/vendor/autoload.php
vendored
Normal file
12
color-convert/vendor/autoload.php
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInita84a1d8e8df377f5b3fe3d96a696369e::getLoader();
|
||||
572
color-convert/vendor/composer/ClassLoader.php
vendored
Normal file
572
color-convert/vendor/composer/ClassLoader.php
vendored
Normal file
|
|
@ -0,0 +1,572 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
352
color-convert/vendor/composer/InstalledVersions.php
vendored
Normal file
352
color-convert/vendor/composer/InstalledVersions.php
vendored
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
21
color-convert/vendor/composer/LICENSE
vendored
Normal file
21
color-convert/vendor/composer/LICENSE
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
10
color-convert/vendor/composer/autoload_classmap.php
vendored
Normal file
10
color-convert/vendor/composer/autoload_classmap.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
);
|
||||
9
color-convert/vendor/composer/autoload_namespaces.php
vendored
Normal file
9
color-convert/vendor/composer/autoload_namespaces.php
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
10
color-convert/vendor/composer/autoload_psr4.php
vendored
Normal file
10
color-convert/vendor/composer/autoload_psr4.php
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Spatie\\Color\\' => array($vendorDir . '/spatie/color/src'),
|
||||
);
|
||||
38
color-convert/vendor/composer/autoload_real.php
vendored
Normal file
38
color-convert/vendor/composer/autoload_real.php
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInita84a1d8e8df377f5b3fe3d96a696369e
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInita84a1d8e8df377f5b3fe3d96a696369e', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInita84a1d8e8df377f5b3fe3d96a696369e', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInita84a1d8e8df377f5b3fe3d96a696369e::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
36
color-convert/vendor/composer/autoload_static.php
vendored
Normal file
36
color-convert/vendor/composer/autoload_static.php
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInita84a1d8e8df377f5b3fe3d96a696369e
|
||||
{
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'S' =>
|
||||
array (
|
||||
'Spatie\\Color\\' => 13,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Spatie\\Color\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/spatie/color/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInita84a1d8e8df377f5b3fe3d96a696369e::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInita84a1d8e8df377f5b3fe3d96a696369e::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInita84a1d8e8df377f5b3fe3d96a696369e::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
68
color-convert/vendor/composer/installed.json
vendored
Normal file
68
color-convert/vendor/composer/installed.json
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"packages": [
|
||||
{
|
||||
"name": "spatie/color",
|
||||
"version": "1.5.3",
|
||||
"version_normalized": "1.5.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/color.git",
|
||||
"reference": "49739265900cabce4640cd26c3266fd8d2cca390"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/color/zipball/49739265900cabce4640cd26c3266fd8d2cca390",
|
||||
"reference": "49739265900cabce4640cd26c3266fd8d2cca390",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest": "^1.22",
|
||||
"phpunit/phpunit": "^6.5||^9.0"
|
||||
},
|
||||
"time": "2022-12-18T12:58:32+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Color\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian De Deyne",
|
||||
"email": "sebastian@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A little library to handle color conversions",
|
||||
"homepage": "https://github.com/spatie/color",
|
||||
"keywords": [
|
||||
"color",
|
||||
"conversion",
|
||||
"rgb",
|
||||
"spatie"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/color/issues",
|
||||
"source": "https://github.com/spatie/color/tree/1.5.3"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/spatie",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"install-path": "../spatie/color"
|
||||
}
|
||||
],
|
||||
"dev": true,
|
||||
"dev-package-names": []
|
||||
}
|
||||
32
color-convert/vendor/composer/installed.php
vendored
Normal file
32
color-convert/vendor/composer/installed.php
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php return array(
|
||||
'root' => array(
|
||||
'pretty_version' => 'dev-gn-pages',
|
||||
'version' => 'dev-gn-pages',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '4eddd01fc39547017b4bd6ac9044468d54f0b53f',
|
||||
'name' => '__root__',
|
||||
'dev' => true,
|
||||
),
|
||||
'versions' => array(
|
||||
'__root__' => array(
|
||||
'pretty_version' => 'dev-gn-pages',
|
||||
'version' => 'dev-gn-pages',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '4eddd01fc39547017b4bd6ac9044468d54f0b53f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'spatie/color' => array(
|
||||
'pretty_version' => '1.5.3',
|
||||
'version' => '1.5.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../spatie/color',
|
||||
'aliases' => array(),
|
||||
'reference' => '49739265900cabce4640cd26c3266fd8d2cca390',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
26
color-convert/vendor/composer/platform_check.php
vendored
Normal file
26
color-convert/vendor/composer/platform_check.php
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 70300)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.3.0". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
15
color-convert/vendor/spatie/color/.editorconfig
vendored
Normal file
15
color-convert/vendor/spatie/color/.editorconfig
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
3
color-convert/vendor/spatie/color/.github/FUNDING.yml
vendored
Normal file
3
color-convert/vendor/spatie/color/.github/FUNDING.yml
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: spatie
|
||||
24
color-convert/vendor/spatie/color/.github/workflows/php-cs-fixer.yml
vendored
Normal file
24
color-convert/vendor/spatie/color/.github/workflows/php-cs-fixer.yml
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
name: Check & fix styling
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: ${{ github.head_ref }}
|
||||
|
||||
- name: Run PHP CS Fixer
|
||||
uses: docker://oskarstark/php-cs-fixer-ga
|
||||
with:
|
||||
args: --config=.php_cs.dist.php --allow-risky=yes
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: Fix styling
|
||||
|
||||
36
color-convert/vendor/spatie/color/.github/workflows/run-tests.yml
vendored
Normal file
36
color-convert/vendor/spatie/color/.github/workflows/run-tests.yml
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
name: Tests
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
php: [8.2, 8.1, 8.0, 7.4, 7.3]
|
||||
stability: [prefer-lowest, prefer-stable]
|
||||
|
||||
name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
|
||||
coverage: none
|
||||
|
||||
- name: Setup problem matchers
|
||||
run: |
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||
- name: Install dependencies
|
||||
run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction
|
||||
|
||||
- name: Execute tests
|
||||
run: vendor/bin/pest
|
||||
28
color-convert/vendor/spatie/color/.github/workflows/update-changelog.yml
vendored
Normal file
28
color-convert/vendor/spatie/color/.github/workflows/update-changelog.yml
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
name: "Update Changelog"
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- name: Update Changelog
|
||||
uses: stefanzweifel/changelog-updater-action@v1
|
||||
with:
|
||||
latest-version: ${{ github.event.release.name }}
|
||||
release-notes: ${{ github.event.release.body }}
|
||||
|
||||
- name: Commit updated CHANGELOG
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
branch: main
|
||||
commit_message: Update CHANGELOG
|
||||
file_pattern: CHANGELOG.md
|
||||
87
color-convert/vendor/spatie/color/CHANGELOG.md
vendored
Executable file
87
color-convert/vendor/spatie/color/CHANGELOG.md
vendored
Executable file
|
|
@ -0,0 +1,87 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to `color` will be documented in this file
|
||||
|
||||
## 1.5.2 - 2022-06-24
|
||||
|
||||
### What's Changed
|
||||
|
||||
- Add RegEx fix to Validate.php too... by @jcogs-design in https://github.com/spatie/color/pull/73
|
||||
- Fix typo in Distance::CIE76. by @Angel5a in https://github.com/spatie/color/pull/76
|
||||
|
||||
### New Contributors
|
||||
|
||||
- @jcogs-design made their first contribution in https://github.com/spatie/color/pull/73
|
||||
- @Angel5a made their first contribution in https://github.com/spatie/color/pull/76
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.1...1.5.2
|
||||
|
||||
## 1.5.1 - 2022-04-12
|
||||
|
||||
## What's Changed
|
||||
|
||||
- Fix rgba opacity by @AstroCorp in https://github.com/spatie/color/pull/67
|
||||
|
||||
## New Contributors
|
||||
|
||||
- @AstroCorp made their first contribution in https://github.com/spatie/color/pull/67
|
||||
|
||||
**Full Changelog**: https://github.com/spatie/color/compare/1.5.0...1.5.1
|
||||
|
||||
## 1.4.0 - 2022-01-05
|
||||
|
||||
- Added support for PHP 8
|
||||
- Added support for CMYK & HSB
|
||||
- Added support for HEX alpha channel
|
||||
- Added support for 3-digit HEX values
|
||||
|
||||
## 1.3.1 - 2021-09-09
|
||||
|
||||
- Fix HEX/HSL conversion bug
|
||||
|
||||
## 1.3.0 - 2021-09-06
|
||||
|
||||
- Added CIELab and XYZ color formats and `Distance` API
|
||||
- Added `Contrast` API
|
||||
|
||||
## 1.2.4 - 2021-02-18
|
||||
|
||||
- Fixed division by zero error on pure white/black convertions ([#42](https://github.com/spatie/color/pull/42))
|
||||
|
||||
## 1.2.3 - 2020-12-10
|
||||
|
||||
- Added support for PHP 8
|
||||
|
||||
## 1.2.2 - 2020-11-18
|
||||
|
||||
- Fix transform RGB value to HSL : division by zero (#38)
|
||||
|
||||
## 1.2.1 - 2020-07-17
|
||||
|
||||
- HSL to RGB fixes
|
||||
|
||||
## 1.2.0 - 2020-06-22
|
||||
|
||||
- Added HSL & HSLA support
|
||||
|
||||
## 1.1.1 - 2017-02-03
|
||||
|
||||
- Fixed validation when a color contained redundant characters at the beginning or end of the string
|
||||
|
||||
## 1.1.0 - 2017-01-13
|
||||
|
||||
- All color formats now implement a `Color` interface
|
||||
- Added a `Factory` class with a `fromString` static method to guess a format
|
||||
- `rgb` and `rgba` values can now contain spaces (e.g. `rgb(255, 255, 255)`)
|
||||
|
||||
## 1.0.2 - 2016-10-17
|
||||
|
||||
- `rgbChannelToHexChannel` now also accepts single single-digit hex values
|
||||
|
||||
## 1.0.1 - 2016-09-22
|
||||
|
||||
- Bugfix (breaking!): Alpha channel values are now a float between 0 and 1
|
||||
|
||||
## 1.0.0 - 2016-09-21
|
||||
|
||||
- First release
|
||||
21
color-convert/vendor/spatie/color/LICENSE.md
vendored
Normal file
21
color-convert/vendor/spatie/color/LICENSE.md
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# The MIT License (MIT)
|
||||
|
||||
Copyright (c) Spatie bvba <info@spatie.be>
|
||||
|
||||
> Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
> of this software and associated documentation files (the "Software"), to deal
|
||||
> in the Software without restriction, including without limitation the rights
|
||||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
> copies of the Software, and to permit persons to whom the Software is
|
||||
> furnished to do so, subject to the following conditions:
|
||||
>
|
||||
> The above copyright notice and this permission notice shall be included in
|
||||
> all copies or substantial portions of the Software.
|
||||
>
|
||||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
> THE SOFTWARE.
|
||||
286
color-convert/vendor/spatie/color/README.md
vendored
Normal file
286
color-convert/vendor/spatie/color/README.md
vendored
Normal file
|
|
@ -0,0 +1,286 @@
|
|||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/support-ukraine.svg?t=1" />](https://supportukrainenow.org)
|
||||
|
||||
# A little library to handle color conversions and comparisons
|
||||
|
||||
[](https://packagist.org/packages/spatie/color)
|
||||
[](LICENSE.md)
|
||||
[](https://travis-ci.org/spatie/color)
|
||||
[](https://scrutinizer-ci.com/g/spatie/color)
|
||||
[](https://packagist.org/packages/spatie/color)
|
||||

|
||||
|
||||
A little library to handle color conversions and comparisons. Currently supports rgb, rgba, hex, hsl, hsla, CIELab, and xyz color formats as well as CIE76, CIE94, and CIEDE2000 color comparison algorithms.
|
||||
|
||||
```php
|
||||
$rgb = Rgb::fromString('rgb(55,155,255)');
|
||||
|
||||
echo $rgb->red(); // 55
|
||||
echo $rgb->green(); // 155
|
||||
echo $rgb->blue(); // 255
|
||||
|
||||
echo $rgb; // rgb(55,155,255)
|
||||
|
||||
$rgba = $rgb->toRgba(); // `Spatie\Color\Rgba`
|
||||
$rgba->alpha(); // 1
|
||||
echo $rgba; // rgba(55,155,255,1)
|
||||
|
||||
$hex = $rgb->toHex(); // `Spatie\Color\Hex`
|
||||
$rgba->alpha(); // ff
|
||||
echo $hex; // #379bff
|
||||
|
||||
$cmyk = $rgb->toCmyk(); // `Spatie\Color\Cmyk`
|
||||
echo $cmyk; // cmyk(78,39,0,0)
|
||||
|
||||
$hsl = $rgb->toHsl(); // `Spatie\Color\Hsl`
|
||||
echo $hsl; // hsl(210,100%,100%)
|
||||
|
||||
$hsb = $rgb->toHsb(); // `Spatie\Color\Hsb`
|
||||
echo $hsb; // hsl(210,78.4%,100%)
|
||||
|
||||
$lab = $rgb->toCIELab();
|
||||
echo $lab; // CIELab(62.91,5.34,-57.73)
|
||||
|
||||
$xyz = $rgb->toXyz();
|
||||
echo $xyz; // xyz(31.3469,31.4749,99.0308)
|
||||
|
||||
$hex2 = Hex::fromString('#2d78c8');
|
||||
|
||||
$ratio = Contrast::ratio(Hex::fromString('#f0fff0'), Hex::fromString('#191970'));
|
||||
echo $ratio; // 15.0
|
||||
|
||||
$cie76_distance = Distance::CIE76($rgb, $hex2);
|
||||
$cie76_distance = Distance::CIE76('rgba(55,155,255,1)', '#2d78c8'); // Outputs the same thing, Factory is built-in to all comparison functions
|
||||
echo $cie76_distance; // 55.89468042667388
|
||||
|
||||
$cie94_distance = Distance::CIE94($rgb, $hex2);
|
||||
echo $cie94_distance; // 13.49091942790753
|
||||
|
||||
$cie94_textiles_distance = Distance::CIE94($rgb, $hex2, 1); // Third parameter optionally sets the application type (0 = Graphic Arts [Default], 1 = Textiles)
|
||||
echo $cie94_textiles_distance; // 7.0926538068477
|
||||
|
||||
$ciede2000_distance = Distance::CIEDE2000($rgb, $hex2);
|
||||
echo $ciede2000_distance; // 12.711957696300898
|
||||
```
|
||||
|
||||
## Support us
|
||||
|
||||
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/color.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/color)
|
||||
|
||||
We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).
|
||||
|
||||
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package via composer:
|
||||
|
||||
```bash
|
||||
composer require spatie/color
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
The `Color` package contains a separate class per color format, which each implement a `Color` interface.
|
||||
|
||||
There are seven classes which implement the `Color` interface:
|
||||
|
||||
- `CIELab`
|
||||
- `Cmyk`
|
||||
- `Hex`
|
||||
- `Hsb`
|
||||
- `Hsl`
|
||||
- `Hsla`
|
||||
- `Rgb`
|
||||
- `Rgba`
|
||||
- `Xyz`
|
||||
|
||||
### `interface Spatie\Color\Color`
|
||||
|
||||
#### `fromString(): Color`
|
||||
|
||||
Parses a color string and returns a `Color` implementation, depending on the format of the input string.
|
||||
|
||||
```php
|
||||
Hex::fromString('#000000');
|
||||
Rgba::fromString('rgba(255, 255, 255, 1)');
|
||||
Hsla::fromString('hsla(360, 100%, 100%, 1)');
|
||||
```
|
||||
|
||||
Throws an `InvalidColorValue` exception if the string can't be parsed.
|
||||
|
||||
> `Rgb`, `Rgba`, `Hsl` and `Hsla` strings are allowed to have spaces. `rgb(0,0,0)` is just as valid as `rgb(0, 0, 0)`.
|
||||
|
||||
#### `red(): int|string`
|
||||
|
||||
Return the value of the `red` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#ff0000')->red(); // 'ff'
|
||||
Rgb::fromString('rgb(255, 0, 0)')->red(); // 255
|
||||
```
|
||||
|
||||
#### `green(): int|string`
|
||||
|
||||
Return the value of the `green` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#00ff00')->green(); // 'ff'
|
||||
Rgb::fromString('rgb(0, 255, 0)')->green(); // 255
|
||||
```
|
||||
|
||||
#### `blue(): int|string`
|
||||
|
||||
Return the value of the `blue` color channel.
|
||||
|
||||
```php
|
||||
Hex::fromString('#0000ff')->blue(); // 'ff'
|
||||
Rgb::fromString('rgb(0, 0, 255)')->blue(); // 255
|
||||
```
|
||||
|
||||
#### `toCmyk(): Cmyk`
|
||||
|
||||
Convert a color to a `Cmyk` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toCmyk();
|
||||
// `Cmyk` instance; 'cmyk(100,100,0,0)'
|
||||
```
|
||||
|
||||
#### `toHex(): Hex`
|
||||
|
||||
Convert a color to a `Hex` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHex();
|
||||
// `Hex` instance; '#0000ff'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
|
||||
#### `toHsb(): Hsb`
|
||||
|
||||
Convert a color to a `Hsb` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsb();
|
||||
// `Hsl` instance; 'hsb(240, 100%, 100%)'
|
||||
```
|
||||
|
||||
#### `toHsl(): Hsl`
|
||||
|
||||
Convert a color to a `Hsl` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsl();
|
||||
// `Hsl` instance; 'hsl(240, 100%, 50%)'
|
||||
```
|
||||
|
||||
When coming from a color format that supports opacity, the opacity will simply be omitted.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgba(0, 0, 255, .5)')->toHsl();
|
||||
// `Hsl` instance; 'hsl(240, 100%, 50%)'
|
||||
```
|
||||
|
||||
#### `toHsla(float $alpha = 1): Hsla`
|
||||
|
||||
Convert a color to a `Hsla` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsla();
|
||||
// `Hsla` instance; 'hsla(240, 100%, 50%, 1.0)'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toHsla(.5);
|
||||
// `Hsla` instance; 'hsla(240, 100%, 50%, 0.5)'
|
||||
```
|
||||
|
||||
#### `toRgb(): Rgb`
|
||||
|
||||
Convert a color to an `Rgb` color.
|
||||
|
||||
```php
|
||||
Hex::fromString('#0000ff')->toRgb();
|
||||
// `Rgb` instance; 'rgb(0, 0, 255)'
|
||||
```
|
||||
|
||||
When coming from a color format that supports opacity, the opacity will simply be omitted.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgb(0, 0, 255, .5)')->toRgb();
|
||||
// `Rgb` instance; 'rgb(0, 0, 255)'
|
||||
```
|
||||
|
||||
#### `toRgba(float $alpha = 1): Rgba`
|
||||
|
||||
Convert a color to a `Rgba` color.
|
||||
|
||||
```php
|
||||
Rgb::fromString('rgb(0, 0, 255)')->toRgba();
|
||||
// `Rgba` instance; 'rgba(0, 0, 255, 1)'
|
||||
```
|
||||
|
||||
When coming from a color format that doesn't support opacity, it can be added by passing it to the `$alpha` parameter.
|
||||
|
||||
```php
|
||||
Rgba::fromString('rgb(0, 0, 255)')->toRgba(.5);
|
||||
// `Rgba` instance; 'rgba(0, 0, 255, .5)'
|
||||
```
|
||||
|
||||
#### `__toString(): string`
|
||||
|
||||
Cast the color to a string.
|
||||
|
||||
```php
|
||||
(string) Rgb::fromString('rgb(0, 0, 255)'); // 'rgb(0,0,255)'
|
||||
(string) Rgba::fromString('rgb(0, 0, 255, .5)'); // 'rgb(0,0,255,0.5)'
|
||||
(string) Hex::fromString('#0000ff'); // '#0000ff'
|
||||
(string) Hsla::fromString('hsl(240, 100%, 50%)'); // 'hsl(240, 100%, 50%)'
|
||||
(string) Hsla::fromString('hsla(240, 100%, 50%, 1.0)'); // 'hsla(240, 100%, 50%, 1.0)'
|
||||
```
|
||||
|
||||
### `Factory::fromString(): Color`
|
||||
|
||||
With the `Factory` class, you can create a color instance from any string (it does an educated guess under the hood). If the string isn't a valid color string in any format, it throws an `InvalidColorValue` exception.
|
||||
|
||||
```php
|
||||
Factory::fromString('rgb(0, 0, 255)'); // `Rgb` instance
|
||||
Factory::fromString('#0000ff'); // `Hex` instance
|
||||
Factory::fromString('hsl(240, 100%, 50%)'); // `Hsl` instance
|
||||
Factory::fromString('Hello world!'); // `InvalidColorValue` exception
|
||||
```
|
||||
|
||||
## Changelog
|
||||
|
||||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
|
||||
|
||||
## Testing
|
||||
|
||||
``` bash
|
||||
$ composer test
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.
|
||||
|
||||
## Security
|
||||
|
||||
If you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.
|
||||
|
||||
## Credits
|
||||
|
||||
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
|
||||
- [All Contributors](../../contributors)
|
||||
|
||||
## About Spatie
|
||||
Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||
46
color-convert/vendor/spatie/color/composer.json
vendored
Normal file
46
color-convert/vendor/spatie/color/composer.json
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "spatie/color",
|
||||
"description": "A little library to handle color conversions",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"color",
|
||||
"conversion",
|
||||
"rgb"
|
||||
],
|
||||
"homepage": "https://github.com/spatie/color",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian De Deyne",
|
||||
"email": "sebastian@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php" : "^7.3|^8.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest": "^1.22",
|
||||
"phpunit/phpunit": "^6.5||^9.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Color\\": "src"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Spatie\\Color\\Test\\": "tests"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "vendor/bin/pest"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"pestphp/pest-plugin": true
|
||||
}
|
||||
}
|
||||
}
|
||||
127
color-convert/vendor/spatie/color/src/CIELab.php
vendored
Normal file
127
color-convert/vendor/spatie/color/src/CIELab.php
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class CIELab implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $l;
|
||||
protected $a;
|
||||
protected $b;
|
||||
|
||||
public function __construct(float $l, float $a, float $b)
|
||||
{
|
||||
Validate::CIELabValue($l, 'l');
|
||||
Validate::CIELabValue($a, 'a');
|
||||
Validate::CIELabValue($b, 'b');
|
||||
|
||||
$this->l = $l;
|
||||
$this->a = $a;
|
||||
$this->b = $b;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::CIELabColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/CIELab\( *(\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d*) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$l, $a, $b] = array_map('trim', $channels);
|
||||
|
||||
return new static($l, $a, $b);
|
||||
}
|
||||
|
||||
public function l(): float
|
||||
{
|
||||
return $this->l;
|
||||
}
|
||||
|
||||
public function a(): float
|
||||
{
|
||||
return $this->a;
|
||||
}
|
||||
|
||||
public function b(): float
|
||||
{
|
||||
return $this->b;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->red();
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->blue();
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->green();
|
||||
}
|
||||
|
||||
public function toCIELab(): self
|
||||
{
|
||||
return new self($this->l, $this->a, $this->b);
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHSL();
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return $this->toXyz()->toRgb();
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
[$x, $y, $z] = Convert::CIELabValueToXyz(
|
||||
$this->l,
|
||||
$this->a,
|
||||
$this->b
|
||||
);
|
||||
|
||||
return new Xyz($x, $y, $z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "CIELab({$this->l},{$this->a},{$this->b})";
|
||||
}
|
||||
}
|
||||
132
color-convert/vendor/spatie/color/src/Cmyk.php
vendored
Normal file
132
color-convert/vendor/spatie/color/src/Cmyk.php
vendored
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Cmyk implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $cyan;
|
||||
protected $magenta;
|
||||
protected $yellow;
|
||||
protected $key;
|
||||
|
||||
public function __construct(float $cyan, float $magenta, float $yellow, float $key)
|
||||
{
|
||||
Validate::cmykValue($cyan, 'cyan');
|
||||
Validate::cmykValue($magenta, 'magenta');
|
||||
Validate::cmykValue($yellow, 'yellow');
|
||||
Validate::cmykValue($key, 'key (black)');
|
||||
|
||||
$this->cyan = $cyan;
|
||||
$this->magenta = $magenta;
|
||||
$this->yellow = $yellow;
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::cmykColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/cmyk\( *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *\)/i', $string, $matches);
|
||||
|
||||
return new static($matches[1] / 100, $matches[2] / 100, $matches[3] / 100, $matches[4] / 100);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key)[2];
|
||||
}
|
||||
|
||||
public function cyan(): float
|
||||
{
|
||||
return $this->cyan;
|
||||
}
|
||||
|
||||
public function magenta(): float
|
||||
{
|
||||
return $this->magenta;
|
||||
}
|
||||
|
||||
public function yellow(): float
|
||||
{
|
||||
return $this->yellow;
|
||||
}
|
||||
|
||||
public function key(): float
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function black(): float
|
||||
{
|
||||
return $this->key;
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return new self($this->cyan, $this->magenta, $this->yellow, $this->key);
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHsl();
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
list($red, $green, $blue) = Convert::cmykValueToRgb($this->cyan, $this->magenta, $this->yellow, $this->key);
|
||||
|
||||
return new Rgb($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgba()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$cyan = round($this->cyan * 100);
|
||||
$magenta = round($this->magenta * 100);
|
||||
$yellow = round($this->yellow * 100);
|
||||
$key = round($this->key * 100);
|
||||
|
||||
return "cmyk({$cyan}%,{$magenta}%,{$yellow}%,{$key}%)";
|
||||
}
|
||||
}
|
||||
34
color-convert/vendor/spatie/color/src/Color.php
vendored
Normal file
34
color-convert/vendor/spatie/color/src/Color.php
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
interface Color
|
||||
{
|
||||
public static function fromString(string $string);
|
||||
|
||||
public function red();
|
||||
|
||||
public function green();
|
||||
|
||||
public function blue();
|
||||
|
||||
public function toCIELab(): CIELab;
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex;
|
||||
|
||||
public function toHsb(): Hsb;
|
||||
|
||||
public function toHsl(): Hsl;
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla;
|
||||
|
||||
public function toRgb(): Rgb;
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba;
|
||||
|
||||
public function toXyz(): Xyz;
|
||||
|
||||
public function toCmyk(): Cmyk;
|
||||
|
||||
public function __toString(): string;
|
||||
}
|
||||
33
color-convert/vendor/spatie/color/src/Contrast.php
vendored
Normal file
33
color-convert/vendor/spatie/color/src/Contrast.php
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Contrast
|
||||
{
|
||||
public static function ratio(Color $a, Color $b): float
|
||||
{
|
||||
if (! $a instanceof Hex) {
|
||||
$a = $a->toHex();
|
||||
}
|
||||
|
||||
if (! $b instanceof Hex) {
|
||||
$b = $b->toHex();
|
||||
}
|
||||
|
||||
$l1 =
|
||||
0.2126 * pow(hexdec($a->red()) / 255, 2.2) +
|
||||
0.7152 * pow(hexdec($a->green()) / 255, 2.2) +
|
||||
0.0722 * pow(hexdec($a->blue()) / 255, 2.2);
|
||||
|
||||
$l2 =
|
||||
0.2126 * pow(hexdec($b->red()) / 255, 2.2) +
|
||||
0.7152 * pow(hexdec($b->green()) / 255, 2.2) +
|
||||
0.0722 * pow(hexdec($b->blue()) / 255, 2.2);
|
||||
|
||||
if ($l1 > $l2) {
|
||||
return (int) (($l1 + 0.05) / ($l2 + 0.05));
|
||||
} else {
|
||||
return (int) (($l2 + 0.05) / ($l1 + 0.05));
|
||||
}
|
||||
}
|
||||
}
|
||||
389
color-convert/vendor/spatie/color/src/Convert.php
vendored
Normal file
389
color-convert/vendor/spatie/color/src/Convert.php
vendored
Normal file
|
|
@ -0,0 +1,389 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Convert
|
||||
{
|
||||
public static function CIELabValueToXyz(float $l, float $a, float $b): array
|
||||
{
|
||||
$y = ($l + 16) / 116;
|
||||
$x = $a / 500 + $y;
|
||||
$z = $y - $b / 200;
|
||||
|
||||
if (pow($y, 3) > 0.008856) {
|
||||
$y = pow($y, 3);
|
||||
} else {
|
||||
$y = ($y - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
if (pow($x, 3) > 0.008856) {
|
||||
$x = pow($x, 3);
|
||||
} else {
|
||||
$x = ($x - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
if (pow($z, 3) > 0.008856) {
|
||||
$z = pow($z, 3);
|
||||
} else {
|
||||
$z = ($z - 16 / 116) / 7.787;
|
||||
}
|
||||
|
||||
$x = round(95.047 * $x, 4);
|
||||
$y = round(100.000 * $y, 4);
|
||||
$z = round(108.883 * $z, 4);
|
||||
|
||||
if ($x > 95.047) {
|
||||
$x = 95.047;
|
||||
}
|
||||
if ($y > 100) {
|
||||
$y = 100;
|
||||
}
|
||||
if ($z > 108.883) {
|
||||
$z = 108.883;
|
||||
}
|
||||
|
||||
return [$x, $y, $z];
|
||||
}
|
||||
|
||||
public static function cmykValueToRgb(float $cyan, float $magenta, float $yellow, float $key): array
|
||||
{
|
||||
return [
|
||||
(int) (255 * (1 - $cyan) * (1 - $key)),
|
||||
(int) (255 * (1 - $magenta) * (1 - $key)),
|
||||
(int) (255 * (1 - $yellow) * (1 - $key)),
|
||||
];
|
||||
}
|
||||
|
||||
public static function rgbValueToCmyk($red, $green, $blue): array
|
||||
{
|
||||
$red /= 255;
|
||||
$green /= 255;
|
||||
$blue /= 255;
|
||||
|
||||
$black = 1 - max($red, $green, $blue);
|
||||
$keyNeg = (1 - $black);
|
||||
|
||||
return [
|
||||
(1 - $red - $black) / ($keyNeg ?: 1),
|
||||
(1 - $green - $black) / ($keyNeg ?: 1),
|
||||
(1 - $blue - $black) / ($keyNeg ?: 1),
|
||||
$black,
|
||||
];
|
||||
}
|
||||
|
||||
public static function hexChannelToRgbChannel(string $hexValue): int
|
||||
{
|
||||
return hexdec($hexValue);
|
||||
}
|
||||
|
||||
public static function rgbChannelToHexChannel(int $rgbValue): string
|
||||
{
|
||||
return str_pad(dechex($rgbValue), 2, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public static function hsbValueToRgb($hue, $saturation, $brightness)
|
||||
{
|
||||
while ($hue > 360) {
|
||||
$hue -= 360.0;
|
||||
}
|
||||
while ($hue < 0) {
|
||||
$hue += 360.0;
|
||||
}
|
||||
|
||||
$hue /= 360;
|
||||
$saturation /= 100;
|
||||
$brightness /= 100;
|
||||
|
||||
if ($saturation == 0) {
|
||||
$R = $G = $B = $brightness * 255;
|
||||
} else {
|
||||
$hue = $hue * 6;
|
||||
$i = floor($hue);
|
||||
$j = $brightness * (1 - $saturation);
|
||||
$k = $brightness * (1 - $saturation * ($hue - $i));
|
||||
$l = $brightness * (1 - $saturation * (1 - ($hue - $i)));
|
||||
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$red = $brightness;
|
||||
$green = $l;
|
||||
$blue = $j;
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$red = $k;
|
||||
$green = $brightness;
|
||||
$blue = $j;
|
||||
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$red = $j;
|
||||
$green = $brightness;
|
||||
$blue = $l;
|
||||
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$red = $j;
|
||||
$green = $k;
|
||||
$blue = $brightness;
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
$red = $l;
|
||||
$green = $j;
|
||||
$blue = $brightness;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
$red = $brightness;
|
||||
$green = $j;
|
||||
$blue = $k;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$R = $red * 255;
|
||||
$G = $green * 255;
|
||||
$B = $blue * 255;
|
||||
}
|
||||
|
||||
return [round($R), round($G), round($B)];
|
||||
}
|
||||
|
||||
public static function hslValueToRgb(float $hue, float $saturation, float $lightness): array
|
||||
{
|
||||
$h = intval((360 + (intval($hue) % 360)) % 360); // hue values can be less than 0 and greater than 360. This normalises them into the range 0-360.
|
||||
|
||||
$c = (1 - abs(2 * ($lightness / 100) - 1)) * ($saturation / 100);
|
||||
$x = $c * (1 - abs(fmod($h / 60, 2) - 1));
|
||||
$m = ($lightness / 100) - ($c / 2);
|
||||
|
||||
if ($h >= 0 && $h <= 60) {
|
||||
return [round(($c + $m) * 255), round(($x + $m) * 255), round($m * 255)];
|
||||
}
|
||||
|
||||
if ($h > 60 && $h <= 120) {
|
||||
return [round(($x + $m) * 255), round(($c + $m) * 255), round($m * 255)];
|
||||
}
|
||||
|
||||
if ($h > 120 && $h <= 180) {
|
||||
return [round($m * 255), round(($c + $m) * 255), round(($x + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 180 && $h <= 240) {
|
||||
return [round($m * 255), round(($x + $m) * 255), round(($c + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 240 && $h <= 300) {
|
||||
return [round(($x + $m) * 255), round($m * 255), round(($c + $m) * 255)];
|
||||
}
|
||||
|
||||
if ($h > 300 && $h <= 360) {
|
||||
return [round(($c + $m) * 255), round($m * 255), round(($x + $m) * 255)];
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbValueToHsb($red, $green, $blue): array
|
||||
{
|
||||
$red /= 255;
|
||||
$green /= 255;
|
||||
$blue /= 255;
|
||||
|
||||
$min = min($red, $green, $blue);
|
||||
$max = max($red, $green, $blue);
|
||||
$delMax = $max - $min;
|
||||
|
||||
$brightness = $max;
|
||||
$hue = 0;
|
||||
|
||||
if ($delMax == 0) {
|
||||
$hue = 0;
|
||||
$saturation = 0;
|
||||
} else {
|
||||
$saturation = $delMax / $max;
|
||||
|
||||
$delR = ((($max - $red) / 6) + ($delMax / 2)) / $delMax;
|
||||
$delG = ((($max - $green) / 6) + ($delMax / 2)) / $delMax;
|
||||
$delB = ((($max - $blue) / 6) + ($delMax / 2)) / $delMax;
|
||||
|
||||
if ($red == $max) {
|
||||
$hue = $delB - $delG;
|
||||
} else {
|
||||
if ($green == $max) {
|
||||
$hue = (1 / 3) + $delR - $delB;
|
||||
} else {
|
||||
if ($blue == $max) {
|
||||
$hue = (2 / 3) + $delG - $delR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($hue < 0) {
|
||||
$hue++;
|
||||
}
|
||||
if ($hue > 1) {
|
||||
$hue--;
|
||||
}
|
||||
}
|
||||
|
||||
return [round($hue, 2) * 360, round($saturation, 2) * 100, round($brightness, 2) * 100];
|
||||
}
|
||||
|
||||
public static function rgbValueToHsl($red, $green, $blue): array
|
||||
{
|
||||
$r = $red / 255;
|
||||
$g = $green / 255;
|
||||
$b = $blue / 255;
|
||||
|
||||
$cmax = max($r, $g, $b);
|
||||
$cmin = min($r, $g, $b);
|
||||
$delta = $cmax - $cmin;
|
||||
|
||||
$hue = 0;
|
||||
if ($delta != 0) {
|
||||
if ($r === $cmax) {
|
||||
$hue = 60 * fmod(($g - $b) / $delta, 6);
|
||||
$hue = $hue < 0 ? $hue + 360 : $hue ;
|
||||
}
|
||||
|
||||
if ($g === $cmax) {
|
||||
$hue = 60 * ((($b - $r) / $delta) + 2);
|
||||
}
|
||||
|
||||
if ($b === $cmax) {
|
||||
$hue = 60 * ((($r - $g) / $delta) + 4);
|
||||
}
|
||||
}
|
||||
|
||||
$lightness = ($cmax + $cmin) / 2;
|
||||
|
||||
$saturation = 0;
|
||||
|
||||
if ($lightness > 0 && $lightness < 1) {
|
||||
$saturation = $delta / (1 - abs((2 * $lightness) - 1));
|
||||
}
|
||||
|
||||
return [$hue, min($saturation, 1) * 100, min($lightness, 1) * 100];
|
||||
}
|
||||
|
||||
public static function rgbValueToXyz($red, $green, $blue): array
|
||||
{
|
||||
$red = $red / 255;
|
||||
$green = $green / 255;
|
||||
$blue = $blue / 255;
|
||||
|
||||
if ($red > 0.04045) {
|
||||
$red = pow((($red + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$red = $red / 12.92;
|
||||
}
|
||||
|
||||
if ($green > 0.04045) {
|
||||
$green = pow((($green + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$green = $green / 12.92;
|
||||
}
|
||||
|
||||
if ($blue > 0.04045) {
|
||||
$blue = pow((($blue + 0.055) / 1.055), 2.4);
|
||||
} else {
|
||||
$blue = $blue / 12.92;
|
||||
}
|
||||
|
||||
$red = $red * 100;
|
||||
$green = $green * 100;
|
||||
$blue = $blue * 100;
|
||||
$x = round($red * 0.4124 + $green * 0.3576 + $blue * 0.1805, 4);
|
||||
$y = round($red * 0.2126 + $green * 0.7152 + $blue * 0.0722, 4);
|
||||
$z = round($red * 0.0193 + $green * 0.1192 + $blue * 0.9505, 4);
|
||||
|
||||
if ($x > 95.047) {
|
||||
$x = 95.047;
|
||||
}
|
||||
if ($y > 100) {
|
||||
$y = 100;
|
||||
}
|
||||
if ($z > 108.883) {
|
||||
$z = 108.883;
|
||||
}
|
||||
|
||||
return [$x, $y, $z];
|
||||
}
|
||||
|
||||
public static function xyzValueToCIELab(float $x, float $y, float $z): array
|
||||
{
|
||||
$x = $x / 95.047;
|
||||
$y = $y / 100.000;
|
||||
$z = $z / 108.883;
|
||||
|
||||
if ($x > 0.008856) {
|
||||
$x = pow($x, 1 / 3);
|
||||
} else {
|
||||
$x = (7.787 * $x) + (16 / 116);
|
||||
}
|
||||
|
||||
if ($y > 0.008856) {
|
||||
$y = pow($y, 1 / 3);
|
||||
} else {
|
||||
$y = (7.787 * $y) + (16 / 116);
|
||||
}
|
||||
|
||||
if ($y > 0.008856) {
|
||||
$l = (116 * $y) - 16;
|
||||
} else {
|
||||
$l = 903.3 * $y;
|
||||
}
|
||||
|
||||
if ($z > 0.008856) {
|
||||
$z = pow($z, 1 / 3);
|
||||
} else {
|
||||
$z = (7.787 * $z) + (16 / 116);
|
||||
}
|
||||
|
||||
$l = round($l, 2);
|
||||
$a = round(500 * ($x - $y), 2);
|
||||
$b = round(200 * ($y - $z), 2);
|
||||
|
||||
return [$l, $a, $b];
|
||||
}
|
||||
|
||||
public static function xyzValueToRgb(float $x, float $y, float $z): array
|
||||
{
|
||||
$x = $x / 100;
|
||||
$y = $y / 100;
|
||||
$z = $z / 100;
|
||||
|
||||
$r = $x * 3.2406 + $y * -1.5372 + $z * -0.4986;
|
||||
$g = $x * -0.9689 + $y * 1.8758 + $z * 0.0415;
|
||||
$b = $x * 0.0557 + $y * -0.2040 + $z * 1.0570;
|
||||
|
||||
if ($r > 0.0031308) {
|
||||
$r = 1.055 * pow($r, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$r = 12.92 * $r;
|
||||
}
|
||||
|
||||
if ($g > 0.0031308) {
|
||||
$g = 1.055 * pow($g, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$g = 12.92 * $g;
|
||||
}
|
||||
|
||||
if ($b > 0.0031308) {
|
||||
$b = 1.055 * pow($b, (1 / 2.4)) - 0.055;
|
||||
} else {
|
||||
$b = 12.92 * $b;
|
||||
}
|
||||
|
||||
$r = intval(max(0, min(255, $r * 255)));
|
||||
$g = intval(max(0, min(255, $g * 255)));
|
||||
$b = intval(max(0, min(255, $b * 255)));
|
||||
|
||||
return [$r, $g, $b];
|
||||
}
|
||||
}
|
||||
155
color-convert/vendor/spatie/color/src/Distance.php
vendored
Normal file
155
color-convert/vendor/spatie/color/src/Distance.php
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Distance
|
||||
{
|
||||
public static function CIE76($color1, $color2): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
if (strval($lab1) === strval($lab2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sum = 0;
|
||||
$sum += pow($lab1->l() - $lab2->l(), 2);
|
||||
$sum += pow($lab1->a() - $lab2->a(), 2);
|
||||
$sum += pow($lab1->b() - $lab2->b(), 2);
|
||||
|
||||
return max(min(sqrt($sum), 100), 0);
|
||||
}
|
||||
|
||||
public static function CIE94($color1, $color2, $textiles = 0): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
$l1 = $lab1->l();
|
||||
$a1 = $lab1->a();
|
||||
$b1 = $lab1->b();
|
||||
|
||||
$l2 = $lab2->l();
|
||||
$a2 = $lab2->a();
|
||||
$b2 = $lab2->b();
|
||||
|
||||
$delta_l = $l1 - $l2;
|
||||
$delta_a = $a1 - $a2;
|
||||
$delta_b = $b1 - $b2;
|
||||
|
||||
$c1 = sqrt(pow($a1, 2) + pow($b1, 2));
|
||||
$c2 = sqrt(pow($a2, 2) + pow($b2, 2));
|
||||
$delta_c = $c1 - $c2;
|
||||
|
||||
$delta_h = pow($delta_a, 2) + pow($delta_b, 2) - pow($delta_c, 2);
|
||||
$delta_h = $delta_h < 0 ? 0 : sqrt($delta_h);
|
||||
|
||||
if ($textiles) {
|
||||
$kl = 2.0;
|
||||
$k1 = .048;
|
||||
$k2 = .014;
|
||||
} else {
|
||||
$kl = 1.0;
|
||||
$k1 = .045;
|
||||
$k2 = .015;
|
||||
}
|
||||
|
||||
$sc = 1.0 + $k1 * $c1;
|
||||
$sh = 1.0 + $k2 * $c1;
|
||||
|
||||
$i = pow($delta_l / $kl, 2) + pow($delta_c / $sc, 2) + pow($delta_h / $sh, 2);
|
||||
|
||||
return $i < 0 ? 0 : sqrt($i);
|
||||
}
|
||||
|
||||
public static function CIEDE2000($color1, $color2): float
|
||||
{
|
||||
if (gettype($color1) === 'string') {
|
||||
$color1 = Factory::fromString($color1);
|
||||
}
|
||||
|
||||
if (gettype($color2) === 'string') {
|
||||
$color2 = Factory::fromString($color2);
|
||||
}
|
||||
|
||||
$lab1 = $color1->toCIELab();
|
||||
$lab2 = $color2->toCIELab();
|
||||
|
||||
$l1 = $lab1->l();
|
||||
$a1 = $lab1->a();
|
||||
$b1 = $lab1->b();
|
||||
|
||||
$l2 = $lab2->l();
|
||||
$a2 = $lab2->a();
|
||||
$b2 = $lab2->b();
|
||||
|
||||
$avg_lp = ($l1 + $l2) / 2;
|
||||
$c1 = sqrt(pow($a1, 2) + pow($b1, 2));
|
||||
$c2 = sqrt(pow($a2, 2) + pow($b2, 2));
|
||||
$avg_c = ($c1 + $c2) / 2;
|
||||
$g = (1 - sqrt(pow($avg_c, 7) / (pow($avg_c, 7) + pow(25, 7)))) / 2;
|
||||
$a1p = $a1 * (1 + $g);
|
||||
$a2p = $a2 * (1 + $g);
|
||||
$c1p = sqrt(pow($a1p, 2) + pow($b1, 2));
|
||||
$c2p = sqrt(pow($a2p, 2) + pow($b2, 2));
|
||||
$avg_cp = ($c1p + $c2p) / 2;
|
||||
$h1p = rad2deg(atan2($b1, $a1p));
|
||||
|
||||
if ($h1p < 0) {
|
||||
$h1p += 360;
|
||||
}
|
||||
|
||||
$h2p = rad2deg(atan2($b2, $a2p));
|
||||
|
||||
if ($h2p < 0) {
|
||||
$h2p += 360;
|
||||
}
|
||||
|
||||
$avg_hp = abs($h1p - $h2p) > 180 ? ($h1p + $h2p + 360) / 2 : ($h1p + $h2p) / 2;
|
||||
$t = 1 - 0.17 * cos(deg2rad($avg_hp - 30)) + 0.24 * cos(deg2rad(2 * $avg_hp)) + 0.32 * cos(deg2rad(3 * $avg_hp + 6)) - 0.2 * cos(deg2rad(4 * $avg_hp - 63));
|
||||
$delta_hp = $h2p - $h1p;
|
||||
|
||||
if (abs($delta_hp) > 180) {
|
||||
if ($h2p <= $h1p) {
|
||||
$delta_hp += 360;
|
||||
} else {
|
||||
$delta_hp -= 360;
|
||||
}
|
||||
}
|
||||
|
||||
$delta_lp = $l2 - $l1;
|
||||
$delta_cp = $c2p - $c1p;
|
||||
$delta_hp = 2 * sqrt($c1p * $c2p) * sin(deg2rad($delta_hp) / 2);
|
||||
|
||||
$s_l = 1 + ((0.015 * pow($avg_lp - 50, 2)) / sqrt(20 + pow($avg_lp - 50, 2)));
|
||||
$s_c = 1 + 0.045 * $avg_cp;
|
||||
$s_h = 1 + 0.015 * $avg_cp * $t;
|
||||
|
||||
$delta_ro = 30 * exp(-(pow(($avg_hp - 275) / 25, 2)));
|
||||
$r_c = 2 * sqrt(pow($avg_cp, 7) / (pow($avg_cp, 7) + pow(25, 7)));
|
||||
$r_t = -$r_c * sin(2 * deg2rad($delta_ro));
|
||||
|
||||
$kl = $kc = $kh = 1;
|
||||
|
||||
$delta_e = sqrt(pow($delta_lp / ($s_l * $kl), 2) + pow($delta_cp / ($s_c * $kc), 2) + pow($delta_hp / ($s_h * $kh), 2) + $r_t * ($delta_cp / ($s_c * $kc)) * ($delta_hp / ($s_h * $kh)));
|
||||
|
||||
return $delta_e;
|
||||
}
|
||||
}
|
||||
100
color-convert/vendor/spatie/color/src/Exceptions/InvalidColorValue.php
vendored
Normal file
100
color-convert/vendor/spatie/color/src/Exceptions/InvalidColorValue.php
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class InvalidColorValue extends Exception
|
||||
{
|
||||
public static function CIELabValueNotInRange(float $value, string $name, float $min, float $max): self
|
||||
{
|
||||
return new static("CIELab value `{$name}` must be a number between $min and $max");
|
||||
}
|
||||
|
||||
public static function rgbChannelValueNotInRange(int $value, string $channel): self
|
||||
{
|
||||
return new static("An rgb values must be an integer between 0 and 255, `{$value}` provided for channel {$channel}.");
|
||||
}
|
||||
|
||||
public static function alphaChannelValueNotInRange(float $value): self
|
||||
{
|
||||
return new static("An alpha values must be a float between 0 and 1, `{$value}` provided.");
|
||||
}
|
||||
|
||||
public static function hexChannelValueHasInvalidLength(string $value): self
|
||||
{
|
||||
$length = strlen($value);
|
||||
|
||||
return new static("Hex values must contain exactly 2 characters, `{$value}` contains {$length} characters.");
|
||||
}
|
||||
|
||||
public static function malformedCIELabColorString(string $string): self
|
||||
{
|
||||
return new static("CIELab color string `{$string}` is malformed. A CIELab color contains 3 comma separated values, wrapped in `CIELab()`, e.g. `CIELab(62.91,5.34,-57.73)`.");
|
||||
}
|
||||
|
||||
public static function cmykValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Cmyk value `{$name}` must be a number between 0 and 1");
|
||||
}
|
||||
|
||||
public static function hexValueContainsInvalidCharacters(string $value): self
|
||||
{
|
||||
return new static("Hex values can only contain numbers or letters from A-F, `{$value}` contains invalid characters.");
|
||||
}
|
||||
|
||||
public static function hsbValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Hsb value `{$name}` must be a number between 0 and 100");
|
||||
}
|
||||
|
||||
public static function hslValueNotInRange(float $value, string $name): self
|
||||
{
|
||||
return new static("Hsl value `{$name}` must be a number between 0 and 100");
|
||||
}
|
||||
|
||||
public static function malformedCmykColorString(string $string): self
|
||||
{
|
||||
return new static("Cmyk color string `{$string}` is malformed. A cmyk color contains cyan, magenta, yellow and key (black) values, wrapped in `cmyk()`, e.g. `cmyk(100%,100%,100%,100%)`.");
|
||||
}
|
||||
|
||||
public static function malformedHexColorString(string $string): self
|
||||
{
|
||||
return new static("Hex color string `{$string}` is malformed. A hex color string starts with a `#` and contains exactly six characters, e.g. `#aabbcc`.");
|
||||
}
|
||||
|
||||
public static function malformedHslColorString(string $string): self
|
||||
{
|
||||
return new static("Hsl color string `{$string}` is malformed. An hsl color contains hue, saturation, and lightness values, wrapped in `hsl()`, e.g. `hsl(300,10%,50%)`.");
|
||||
}
|
||||
|
||||
public static function malformedHslaColorString(string $string): self
|
||||
{
|
||||
return new static("Hsla color string `{$string}` is malformed. An hsla color contains hue, saturation, lightness and alpha values, wrapped in `hsl()`, e.g. `hsl(300,10%,50%,0.25)`.");
|
||||
}
|
||||
|
||||
public static function malformedRgbColorString(string $string): self
|
||||
{
|
||||
return new static("Rgb color string `{$string}` is malformed. An rgb color contains 3 comma separated values between 0 and 255, wrapped in `rgb()`, e.g. `rgb(0,0,255)`.");
|
||||
}
|
||||
|
||||
public static function malformedRgbaColorString(string $string): self
|
||||
{
|
||||
return new static("Rgba color string `{$string}` is malformed. An rgba color contains 3 comma separated values between 0 and 255 with an alpha value between 0 and 1, wrapped in `rgba()`, e.g. `rgb(0,0,255,0.5)`.");
|
||||
}
|
||||
|
||||
public static function malformedColorString(string $string): self
|
||||
{
|
||||
return new static("Color string `{$string}` doesn't match any of the available colors.");
|
||||
}
|
||||
|
||||
public static function malformedXyzColorString(string $string): self
|
||||
{
|
||||
return new static("Xyz color string `{$string}` is malformed. An xyz color contains 3 comma separated values, wrapped in `xyz()`, e.g. `xyz(31.3469,31.4749,99.0308)`.");
|
||||
}
|
||||
|
||||
public static function xyzValueNotInRange(float $value, string $name, float $min, float $max): self
|
||||
{
|
||||
return new static("Xyz value `{$name}` must be a number between $min and $max");
|
||||
}
|
||||
}
|
||||
38
color-convert/vendor/spatie/color/src/Factory.php
vendored
Normal file
38
color-convert/vendor/spatie/color/src/Factory.php
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
use Spatie\Color\Exceptions\InvalidColorValue;
|
||||
|
||||
class Factory
|
||||
{
|
||||
public static function fromString(string $string): Color
|
||||
{
|
||||
$colorClasses = static::getColorClasses();
|
||||
|
||||
foreach ($colorClasses as $colorClass) {
|
||||
try {
|
||||
return $colorClass::fromString($string);
|
||||
} catch (InvalidColorValue $e) {
|
||||
// Catch the exception but never throw it.
|
||||
}
|
||||
}
|
||||
|
||||
throw InvalidColorValue::malformedColorString($string);
|
||||
}
|
||||
|
||||
protected static function getColorClasses(): array
|
||||
{
|
||||
return [
|
||||
CIELab::class,
|
||||
Cmyk::class,
|
||||
Hex::class,
|
||||
Hsb::class,
|
||||
Hsl::class,
|
||||
Hsla::class,
|
||||
Rgb::class,
|
||||
Rgba::class,
|
||||
Xyz::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
152
color-convert/vendor/spatie/color/src/Hex.php
vendored
Normal file
152
color-convert/vendor/spatie/color/src/Hex.php
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hex implements Color
|
||||
{
|
||||
/** @var string */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
protected $alpha = 'ff';
|
||||
|
||||
public function __construct(string $red, string $green, string $blue, string $alpha = 'ff')
|
||||
{
|
||||
Validate::hexChannelValue($red, 'red');
|
||||
Validate::hexChannelValue($green, 'green');
|
||||
Validate::hexChannelValue($blue, 'blue');
|
||||
Validate::hexChannelValue($alpha, 'alpha');
|
||||
|
||||
$this->red = strtolower($red);
|
||||
$this->green = strtolower($green);
|
||||
$this->blue = strtolower($blue);
|
||||
$this->alpha = strtolower($alpha);
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hexColorString($string);
|
||||
|
||||
$string = ltrim($string, '#');
|
||||
|
||||
switch (strlen($string)) {
|
||||
case 3:
|
||||
[$red, $green, $blue] = str_split($string);
|
||||
$red .= $red;
|
||||
$green .= $green;
|
||||
$blue .= $blue;
|
||||
$alpha = 'ff';
|
||||
|
||||
break;
|
||||
|
||||
case 4:
|
||||
[$red, $green, $blue, $alpha] = str_split($string);
|
||||
$red .= $red;
|
||||
$green .= $green;
|
||||
$blue .= $blue;
|
||||
$alpha .= $alpha;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case 6:
|
||||
[$red, $green, $blue] = str_split($string, 2);
|
||||
$alpha = 'ff';
|
||||
|
||||
break;
|
||||
|
||||
case 8:
|
||||
[$red, $green, $blue, $alpha] = str_split($string, 2);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return new static($red, $green, $blue, $alpha);
|
||||
}
|
||||
|
||||
public function red(): string
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): string
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): string
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function alpha(): string
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue, $alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
Convert::hexChannelToRgbChannel($this->red),
|
||||
Convert::hexChannelToRgbChannel($this->green),
|
||||
Convert::hexChannelToRgbChannel($this->blue)
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
Convert::hexChannelToRgbChannel($this->red),
|
||||
Convert::hexChannelToRgbChannel($this->green),
|
||||
Convert::hexChannelToRgbChannel($this->blue)
|
||||
);
|
||||
|
||||
return new Hsla($hue, $saturation, $lightness, $alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb(
|
||||
Convert::hexChannelToRgbChannel($this->red),
|
||||
Convert::hexChannelToRgbChannel($this->green),
|
||||
Convert::hexChannelToRgbChannel($this->blue)
|
||||
);
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "#{$this->red}{$this->green}{$this->blue}" . ($this->alpha !== 'ff' ? $this->alpha : '');
|
||||
}
|
||||
}
|
||||
121
color-convert/vendor/spatie/color/src/Hsb.php
vendored
Normal file
121
color-convert/vendor/spatie/color/src/Hsb.php
vendored
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsb implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $brightness;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $brightness)
|
||||
{
|
||||
Validate::hsbValue($hue, 'hue');
|
||||
Validate::hsbValue($saturation, 'saturation');
|
||||
Validate::hsbValue($brightness, 'brightness');
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->brightness = $brightness;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hsbColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/hs[vb]\( *(-?\d{1,3}) *, *(\d{1,3})%? *, *(\d{1,3})%? *\)/i', $string, $matches);
|
||||
|
||||
return new static($matches[1], $matches[2], $matches[3]);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function brightness(): float
|
||||
{
|
||||
return $this->brightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hsbValueToRgb($this->hue, $this->saturation, $this->brightness)[2];
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return new self($this->hue, $this->saturation, $this->brightness);
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return new Hex(
|
||||
Convert::rgbChannelToHexChannel($this->red()),
|
||||
Convert::rgbChannelToHexChannel($this->green()),
|
||||
Convert::rgbChannelToHexChannel($this->blue()),
|
||||
$alpha
|
||||
);
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHsl();
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$brightness = round($this->brightness);
|
||||
|
||||
return "hsb({$hue},{$saturation}%,{$brightness}%)";
|
||||
}
|
||||
}
|
||||
120
color-convert/vendor/spatie/color/src/Hsl.php
vendored
Normal file
120
color-convert/vendor/spatie/color/src/Hsl.php
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsl implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $lightness;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $lightness)
|
||||
{
|
||||
Validate::hslValue($saturation, 'saturation');
|
||||
Validate::hslValue($lightness, 'lightness');
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->lightness = $lightness;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hslColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/hsl\( *(-?\d{1,3}) *, *(\d{1,3})%? *, *(\d{1,3})%? *\)/i', $string, $matches);
|
||||
|
||||
return new static($matches[1], $matches[2], $matches[3]);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function lightness(): float
|
||||
{
|
||||
return $this->lightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[2];
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return new Hex(
|
||||
Convert::rgbChannelToHexChannel($this->red()),
|
||||
Convert::rgbChannelToHexChannel($this->green()),
|
||||
Convert::rgbChannelToHexChannel($this->blue()),
|
||||
$alpha
|
||||
);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): self
|
||||
{
|
||||
return new self($this->hue(), $this->saturation(), $this->lightness());
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
return new Hsla($this->hue(), $this->saturation(), $this->lightness(), $alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$lightness = round($this->lightness);
|
||||
|
||||
return "hsl({$hue},{$saturation}%,{$lightness}%)";
|
||||
}
|
||||
}
|
||||
134
color-convert/vendor/spatie/color/src/Hsla.php
vendored
Normal file
134
color-convert/vendor/spatie/color/src/Hsla.php
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Hsla implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $hue;
|
||||
protected $saturation;
|
||||
protected $lightness;
|
||||
protected $alpha;
|
||||
|
||||
public function __construct(float $hue, float $saturation, float $lightness, float $alpha = 1.0)
|
||||
{
|
||||
Validate::hslValue($saturation, 'saturation');
|
||||
Validate::hslValue($lightness, 'lightness');
|
||||
Validate::alphaChannelValue($alpha);
|
||||
|
||||
$this->hue = $hue;
|
||||
$this->saturation = $saturation;
|
||||
$this->lightness = $lightness;
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::hslaColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/hsla\( *(\d{1,3}) *, *(\d{1,3})%? *, *(\d{1,3})%? *, *([0-1](\.\d{1,2})?) *\)/i', $string, $matches);
|
||||
|
||||
return new static($matches[1], $matches[2], $matches[3], $matches[4]);
|
||||
}
|
||||
|
||||
public function hue(): float
|
||||
{
|
||||
return $this->hue;
|
||||
}
|
||||
|
||||
public function saturation(): float
|
||||
{
|
||||
return $this->saturation;
|
||||
}
|
||||
|
||||
public function lightness(): float
|
||||
{
|
||||
return $this->lightness;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[0];
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[1];
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return Convert::hslValueToRgb($this->hue, $this->saturation, $this->lightness)[2];
|
||||
}
|
||||
|
||||
public function alpha(): float
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function contrast(): self
|
||||
{
|
||||
return Contrast::make($this->toHex())->toHsla($this->alpha());
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return new Hex(
|
||||
Convert::rgbChannelToHexChannel($this->red()),
|
||||
Convert::rgbChannelToHexChannel($this->green()),
|
||||
Convert::rgbChannelToHexChannel($this->blue()),
|
||||
$alpha
|
||||
);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): self
|
||||
{
|
||||
return new self($this->hue(), $this->saturation(), $this->lightness(), $alpha);
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return new Hsl($this->hue(), $this->saturation(), $this->lightness());
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red(), $this->green(), $this->blue());
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return new Rgba($this->red(), $this->green(), $this->blue(), $alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$hue = round($this->hue);
|
||||
$saturation = round($this->saturation);
|
||||
$lightness = round($this->lightness);
|
||||
$alpha = round($this->alpha, 2);
|
||||
|
||||
return "hsla({$hue},{$saturation}%,{$lightness}%,{$alpha})";
|
||||
}
|
||||
}
|
||||
127
color-convert/vendor/spatie/color/src/Rgb.php
vendored
Normal file
127
color-convert/vendor/spatie/color/src/Rgb.php
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Rgb implements Color
|
||||
{
|
||||
/** @var int */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
|
||||
public function __construct(int $red, int $green, int $blue)
|
||||
{
|
||||
Validate::rgbChannelValue($red, 'red');
|
||||
Validate::rgbChannelValue($green, 'green');
|
||||
Validate::rgbChannelValue($blue, 'blue');
|
||||
|
||||
$this->red = $red;
|
||||
$this->green = $green;
|
||||
$this->blue = $blue;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::rgbColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/rgb\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3}) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$red, $green, $blue] = array_map('trim', $channels);
|
||||
|
||||
return new static($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toXyz()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
list($cyan, $magenta, $yellow, $key) = Convert::rgbValueToCmyk($this->red, $this->green, $this->blue);
|
||||
|
||||
return new Cmyk($cyan, $magenta, $yellow, $key);
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return new Hex(
|
||||
Convert::rgbChannelToHexChannel($this->red),
|
||||
Convert::rgbChannelToHexChannel($this->green),
|
||||
Convert::rgbChannelToHexChannel($this->blue),
|
||||
$alpha
|
||||
);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
list($hue, $saturation, $brightness) = Convert::rgbValueToHsb($this->red, $this->green, $this->blue);
|
||||
|
||||
return new Hsb($hue, $saturation, $brightness);
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsla($hue, $saturation, $lightness, $alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue);
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return new Rgba($this->red, $this->green, $this->blue, $alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
[$x, $y, $z] = Convert::rgbValueToXyz(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Xyz($x, $y, $z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "rgb({$this->red},{$this->green},{$this->blue})";
|
||||
}
|
||||
}
|
||||
124
color-convert/vendor/spatie/color/src/Rgba.php
vendored
Normal file
124
color-convert/vendor/spatie/color/src/Rgba.php
vendored
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Rgba implements Color
|
||||
{
|
||||
/** @var int */
|
||||
protected $red;
|
||||
protected $green;
|
||||
protected $blue;
|
||||
|
||||
/** @var float */
|
||||
protected $alpha;
|
||||
|
||||
public function __construct(int $red, int $green, int $blue, float $alpha)
|
||||
{
|
||||
Validate::rgbChannelValue($red, 'red');
|
||||
Validate::rgbChannelValue($green, 'green');
|
||||
Validate::rgbChannelValue($blue, 'blue');
|
||||
Validate::alphaChannelValue($alpha);
|
||||
|
||||
$this->red = $red;
|
||||
$this->green = $green;
|
||||
$this->blue = $blue;
|
||||
$this->alpha = $alpha;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::rgbaColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/rgba\( *(\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1]*(\.\d{1,})?) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$red, $green, $blue, $alpha] = array_map('trim', $channels);
|
||||
|
||||
return new static($red, $green, $blue, $alpha);
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
return $this->red;
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
return $this->green;
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
return $this->blue;
|
||||
}
|
||||
|
||||
public function alpha(): float
|
||||
{
|
||||
return $this->alpha;
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
return $this->toRgb()->toCIELab();
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsl($hue, $saturation, $lightness);
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
[$hue, $saturation, $lightness] = Convert::rgbValueToHsl(
|
||||
$this->red,
|
||||
$this->green,
|
||||
$this->blue
|
||||
);
|
||||
|
||||
return new Hsla($hue, $saturation, $lightness, $alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
return new Rgb($this->red, $this->green, $this->blue);
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): self
|
||||
{
|
||||
return new self($this->red, $this->green, $this->blue, $alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): Xyz
|
||||
{
|
||||
return $this->toRgb()->toXyz();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$alpha = number_format($this->alpha, 2);
|
||||
|
||||
return "rgba({$this->red},{$this->green},{$this->blue},{$alpha})";
|
||||
}
|
||||
}
|
||||
155
color-convert/vendor/spatie/color/src/Validate.php
vendored
Normal file
155
color-convert/vendor/spatie/color/src/Validate.php
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
use Spatie\Color\Exceptions\InvalidColorValue;
|
||||
|
||||
class Validate
|
||||
{
|
||||
public static function CIELabValue(float $value, string $name): void
|
||||
{
|
||||
if ($name === 'l' && ($value < 0 || $value > 100)) {
|
||||
throw InvalidColorValue::CIELabValueNotInRange($value, $name, 0, 100);
|
||||
}
|
||||
|
||||
if (($name === 'a' || $name === 'b') && ($value < -110 || $value > 110)) {
|
||||
throw InvalidColorValue::CIELabValueNotInRange($value, $name, -110, 110);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CIELabColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *CIELab\( *\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *, *-?\d{1,3}\.?\d* *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedCIELabColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cmykValue(float $value, string $name): void
|
||||
{
|
||||
if ($value < 0 || $value > 1) {
|
||||
throw InvalidColorValue::cmykValueNotInRange($value, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbChannelValue(int $value, string $channel): void
|
||||
{
|
||||
if ($value < 0 || $value > 255) {
|
||||
throw InvalidColorValue::rgbChannelValueNotInRange($value, $channel);
|
||||
}
|
||||
}
|
||||
|
||||
public static function alphaChannelValue(float $value): void
|
||||
{
|
||||
if ($value < 0 || $value > 1) {
|
||||
throw InvalidColorValue::alphaChannelValueNotInRange($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hexChannelValue(string $value): void
|
||||
{
|
||||
if (strlen($value) !== 2) {
|
||||
throw InvalidColorValue::hexChannelValueHasInvalidLength($value);
|
||||
}
|
||||
|
||||
if (! preg_match('/[a-f0-9]{2}/i', $value)) {
|
||||
throw InvalidColorValue::hexValueContainsInvalidCharacters($value);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hsbValue(float $value, string $name): void
|
||||
{
|
||||
switch ($name) {
|
||||
case 'hue':
|
||||
if ($value < 0 || $value > 360) {
|
||||
throw InvalidColorValue::hsbValueNotInRange($value, $name);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($value < 0 || $value > 100) {
|
||||
throw InvalidColorValue::hsbValueNotInRange($value, $name);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslValue(float $value, string $name): void
|
||||
{
|
||||
if ($value < 0 || $value > 100) {
|
||||
throw InvalidColorValue::hslValueNotInRange($value, $name);
|
||||
}
|
||||
}
|
||||
|
||||
public static function cmykColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *cmyk\( *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *, *(\d{1,3})%? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedCmykColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *rgb\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedRgbColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function rgbaColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *rgba\( *\d{1,3} *, *\d{1,3} *, *\d{1,3} *, *[0-1]*(\.\d{1,})? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedRgbaColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hexColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^#(?:[a-f0-9]{3}|[a-f0-9]{4}|[a-f0-9]{6}|[a-f0-9]{8})$/i', $string)) {
|
||||
throw InvalidColorValue::malformedHexColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hsbColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *hs[vb]\( *-?\d{1,3} *, *\d{1,3}%? *, *\d{1,3}%? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedHslColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *hsl\( *-?\d{1,3} *, *\d{1,3}%? *, *\d{1,3}%? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedHslColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function hslaColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *hsla\( *\d{1,3} *, *\d{1,3}%? *, *\d{1,3}%? *, *[0-1](\.\d{1,2})? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedHslaColorString($string);
|
||||
}
|
||||
}
|
||||
|
||||
public static function xyzValue(float $value, string $name): void
|
||||
{
|
||||
if ($name === 'x' && ($value < 0 || $value > 95.047)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 95.047);
|
||||
}
|
||||
|
||||
if ($name === 'y' && ($value < 0 || $value > 100)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 100);
|
||||
}
|
||||
|
||||
if ($name === 'z' && ($value < 0 || $value > 108.883)) {
|
||||
throw InvalidColorValue::xyzValueNotInRange($value, $name, 0, 108.883);
|
||||
}
|
||||
}
|
||||
|
||||
public static function xyzColorString($string): void
|
||||
{
|
||||
if (! preg_match('/^ *xyz\( *\d{1,2}\.?\d+? *, *\d{1,3}\.?\d+? *, *\d{1,3}\.?\d+? *\) *$/i', $string)) {
|
||||
throw InvalidColorValue::malformedXyzColorString($string);
|
||||
}
|
||||
}
|
||||
}
|
||||
133
color-convert/vendor/spatie/color/src/Xyz.php
vendored
Normal file
133
color-convert/vendor/spatie/color/src/Xyz.php
vendored
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
namespace Spatie\Color;
|
||||
|
||||
class Xyz implements Color
|
||||
{
|
||||
/** @var float */
|
||||
protected $x;
|
||||
protected $y;
|
||||
protected $z;
|
||||
|
||||
public function __construct(float $x, float $y, float $z)
|
||||
{
|
||||
Validate::xyzValue($x, 'x');
|
||||
Validate::xyzValue($y, 'y');
|
||||
Validate::xyzValue($z, 'z');
|
||||
|
||||
$this->x = $x;
|
||||
$this->y = $y;
|
||||
$this->z = $z;
|
||||
}
|
||||
|
||||
public static function fromString(string $string)
|
||||
{
|
||||
Validate::xyzColorString($string);
|
||||
|
||||
$matches = null;
|
||||
preg_match('/xyz\( *(\d{1,2}\.?\d+? *, *\d{1,3}\.?\d+? *, *\d{1,3}\.?\d+?) *\)/i', $string, $matches);
|
||||
|
||||
$channels = explode(',', $matches[1]);
|
||||
[$x, $y, $z] = array_map('trim', $channels);
|
||||
|
||||
return new static($x, $y, $z);
|
||||
}
|
||||
|
||||
public function x(): float
|
||||
{
|
||||
return $this->x;
|
||||
}
|
||||
|
||||
public function y(): float
|
||||
{
|
||||
return $this->y;
|
||||
}
|
||||
|
||||
public function z(): float
|
||||
{
|
||||
return $this->z;
|
||||
}
|
||||
|
||||
public function red(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->red();
|
||||
}
|
||||
|
||||
public function blue(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->blue();
|
||||
}
|
||||
|
||||
public function green(): int
|
||||
{
|
||||
$rgb = $this->toRgb();
|
||||
|
||||
return $rgb->green();
|
||||
}
|
||||
|
||||
public function toCIELab(): CIELab
|
||||
{
|
||||
[$l, $a, $b] = Convert::xyzValueToCIELab(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z
|
||||
);
|
||||
|
||||
return new CIELab($l, $a, $b);
|
||||
}
|
||||
|
||||
public function toCmyk(): Cmyk
|
||||
{
|
||||
return $this->toRgb()->toCmyk();
|
||||
}
|
||||
|
||||
public function toHex(string $alpha = 'ff'): Hex
|
||||
{
|
||||
return $this->toRgb()->toHex($alpha);
|
||||
}
|
||||
|
||||
public function toHsb(): Hsb
|
||||
{
|
||||
return $this->toRgb()->toHsb();
|
||||
}
|
||||
|
||||
public function toHsl(): Hsl
|
||||
{
|
||||
return $this->toRgb()->toHSL();
|
||||
}
|
||||
|
||||
public function toHsla(float $alpha = 1): Hsla
|
||||
{
|
||||
return $this->toRgb()->toHsla($alpha);
|
||||
}
|
||||
|
||||
public function toRgb(): Rgb
|
||||
{
|
||||
[$red, $green, $blue] = Convert::xyzValueToRgb(
|
||||
$this->x,
|
||||
$this->y,
|
||||
$this->z
|
||||
);
|
||||
|
||||
return new Rgb($red, $green, $blue);
|
||||
}
|
||||
|
||||
public function toRgba(float $alpha = 1): Rgba
|
||||
{
|
||||
return $this->toRgb()->toRgba($alpha);
|
||||
}
|
||||
|
||||
public function toXyz(): self
|
||||
{
|
||||
return new self($this->x, $this->y, $this->z);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "xyz({$this->x},{$this->y},{$this->z})";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue