Merge branch 'NewFeatures' into Features-DB_IO_SQLite
This commit is contained in:
@@ -156,12 +156,32 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
public function providerMultiplyMatrices(): array
|
public function providerMultiplyMatrices(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'single' => [
|
'[3] x [3] => [3x1]' => [
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[14]
|
[14]
|
||||||
],
|
],
|
||||||
'double first' => [
|
'[3] x [3x1]' => [
|
||||||
|
[1, 2, 3],
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[14]
|
||||||
|
],
|
||||||
|
'[3] x [3x1]' => [
|
||||||
|
[1, 2, 3],
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[14]
|
||||||
|
],
|
||||||
|
'[1x3L] x [3x1]' => [
|
||||||
|
[[1, 2, 3]],
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[14]
|
||||||
|
],
|
||||||
|
'[1x3] x [3x1]' => [
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[1, 2, 3]
|
||||||
|
],
|
||||||
|
'[2x3] x [3] => [3x1]' => [
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3]
|
[1, 2, 3]
|
||||||
@@ -172,7 +192,18 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
14
|
14
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'double both' => [
|
'[2x3] x [3x1]' => [
|
||||||
|
[
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3]
|
||||||
|
],
|
||||||
|
[[1], [2], [3]],
|
||||||
|
[
|
||||||
|
14,
|
||||||
|
14
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'[2x3] x [2x3] => [3x3]' => [
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
@@ -186,7 +217,37 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
[3, 6, 9]
|
[3, 6, 9]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'tripple first, single second' => [
|
'[2x3] x [3x3]' => [
|
||||||
|
[
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
[0, 0, 0],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[3, 6, 9],
|
||||||
|
[3, 6, 9]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'[2x3] x [3x2]' => [
|
||||||
|
'a' => [
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
],
|
||||||
|
'b' => [
|
||||||
|
[1, 1],
|
||||||
|
[2, 2],
|
||||||
|
[3, 3],
|
||||||
|
],
|
||||||
|
'prod' => [
|
||||||
|
[14, 14],
|
||||||
|
[14, 14],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'[3x3] x [3] => [1x3]' => [
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
@@ -199,7 +260,7 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
14
|
14
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'tripple first, double second' => [
|
'[3x3] x [2x3] => [3x3]' => [
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
@@ -215,7 +276,24 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
[3, 6, 9],
|
[3, 6, 9],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'single first, tripple second' => [
|
'[3x3] x [3x3]' => [
|
||||||
|
[
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[1, 2, 3],
|
||||||
|
[1, 2, 3],
|
||||||
|
// [0, 0, 0],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[3, 6, 9],
|
||||||
|
[3, 6, 9],
|
||||||
|
[3, 6, 9],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'[3] x [3x3]' => [
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
@@ -226,7 +304,7 @@ final class CoreLibsConvertMathTest extends TestCase
|
|||||||
[6, 12, 18],
|
[6, 12, 18],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'double first, tripple second' => [
|
'[2x3] x [3x3]' => [
|
||||||
[
|
[
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
[1, 2, 3],
|
[1, 2, 3],
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
"phpstan/phpstan": "^1.12",
|
"phpstan/phpstan": "^1.12",
|
||||||
"phan/phan": "^5.4",
|
"phan/phan": "^5.4",
|
||||||
"phpstan/extension-installer": "^1.4",
|
"phpstan/extension-installer": "^1.4",
|
||||||
"phpstan/phpstan-strict-rules": "^1.6",
|
|
||||||
"phpunit/phpunit": "^9",
|
"phpunit/phpunit": "^9",
|
||||||
"phpstan/phpstan-deprecation-rules": "^1.2",
|
"phpstan/phpstan-deprecation-rules": "^1.2",
|
||||||
"yamadashy/phpstan-friendly-formatter": "^1.1"
|
"yamadashy/phpstan-friendly-formatter": "^1.1"
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ function display(string $color, string $text, string $text_add): string
|
|||||||
["{COLOR}", "{TEXT}", "{CSS}"],
|
["{COLOR}", "{TEXT}", "{CSS}"],
|
||||||
[
|
[
|
||||||
$color,
|
$color,
|
||||||
$text . ($text_add ? '<br>' . $text_add : ''),
|
$text . (!empty($text_add) ? '<br>' . $text_add : ''),
|
||||||
$css
|
$css
|
||||||
],
|
],
|
||||||
$template
|
$template
|
||||||
@@ -123,22 +123,16 @@ $hsl_from_hsb = Color::hsbToHsl($hsb);
|
|||||||
print "HSL from HSB: " . DgS::printAr($hsl_from_hsb) . "<br>";
|
print "HSL from HSB: " . DgS::printAr($hsl_from_hsb) . "<br>";
|
||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
print "<h2>LEGACY</h2>";
|
|
||||||
|
|
||||||
// A(out of bounds)
|
// A(out of bounds)
|
||||||
try {
|
try {
|
||||||
print "C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: "
|
print "C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: "
|
||||||
. CoreLibs\Convert\Colors::rgb2hex(-1, -1, -1) . "<br>";
|
. (new Coordinates\RGB([-1, -1, -1]))->returnAsHex() . "<br>";
|
||||||
} catch (\LengthException $e) {
|
} catch (\LengthException $e) {
|
||||||
print "*Exception: " . $e->getMessage() . "<br>" . $e . "<br>";
|
print "*Exception: " . $e->getMessage() . "<br><pre>" . print_r($e, true) . "</pre><br>";
|
||||||
}
|
|
||||||
try {
|
|
||||||
print "\$C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: "
|
|
||||||
. $color_class::rgb2hex(-1, -1, -1) . "<br>";
|
|
||||||
} catch (\LengthException $e) {
|
|
||||||
print "**Exception: " . $e->getMessage() . "<br><pre>" . print_r($e, true) . "</pre><br>";
|
|
||||||
}
|
}
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
|
print "<h2>LEGACY</h2>";
|
||||||
// B(valid)
|
// B(valid)
|
||||||
$rgb = [50, 20, 30];
|
$rgb = [50, 20, 30];
|
||||||
$hex = '#0a141e';
|
$hex = '#0a141e';
|
||||||
@@ -189,13 +183,16 @@ $s = rand(15, 70);
|
|||||||
$b = 100;
|
$b = 100;
|
||||||
$l = 50;
|
$l = 50;
|
||||||
print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "<br>";
|
print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "<br>";
|
||||||
print "RANDOM hsb->rgb: <pre>" . DgS::printAr(SetVarType::setArray(Colors::hsb2rgb($h, $s, $b))) . "</pre><br>";
|
print "RANDOM hsb->rgb: <pre>"
|
||||||
print "RANDOM hsl->rgb: <pre>" . DgS::printAr(SetVarType::setArray(Colors::hsl2rgb($h, $s, $l))) . "</pre><br>";
|
. DgS::printAr(SetVarType::setArray(Color::hsbToRgb(new Coordinates\HSB([$h, $s, $b])))) . "</pre><br>";
|
||||||
|
print "RANDOM hsl->rgb: <pre>"
|
||||||
|
. DgS::printAr(SetVarType::setArray(Color::hslToRgb(new Coordinates\HSL([$h, $s, $l])))) . "</pre><br>";
|
||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
|
|
||||||
$rgb = [0, 0, 0];
|
$rgb = [0, 0, 0];
|
||||||
print "rgb 0,0,0: " . Dgs::printAr($rgb) . " => " . Dgs::printAr(Colors::rgb2hsb($rgb[0], $rgb[1], $rgb[2])) . "<br>";
|
print "rgb 0,0,0: " . Dgs::printAr($rgb) . " => "
|
||||||
|
. Dgs::printAr(Color::rgbToHsb(new Coordinates\RGB([$rgb[0], $rgb[1], $rgb[2]]))) . "<br>";
|
||||||
|
|
||||||
print "<hr>";
|
print "<hr>";
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ $log = new CoreLibs\Logging\Logging([
|
|||||||
'log_file_id' => $LOG_FILE_ID,
|
'log_file_id' => $LOG_FILE_ID,
|
||||||
'log_per_date' => true,
|
'log_per_date' => true,
|
||||||
]);
|
]);
|
||||||
$_math = new CoreLibs\Convert\Math();
|
|
||||||
$math_class = 'CoreLibs\Convert\Math';
|
$math_class = 'CoreLibs\Convert\Math';
|
||||||
|
|
||||||
// define a list of from to color sets for conversion test
|
// define a list of from to color sets for conversion test
|
||||||
@@ -35,13 +34,9 @@ print "<body>";
|
|||||||
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
print '<div><a href="class_test.php">Class Test Master</a></div>';
|
||||||
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
||||||
|
|
||||||
print "FCEIL: " . $_math->fceil(5.1234567890, 5) . "<br>";
|
|
||||||
print "FLOORP: " . $_math->floorp(5123456, -3) . "<br>";
|
|
||||||
print "FLOORP: " . $_math->floorp(5123456, -10) . "<br>";
|
|
||||||
print "INITNUMERIC: " . $_math->initNumeric('123') . "<br>";
|
|
||||||
|
|
||||||
print "S-FCEIL: " . $math_class::fceil(5.1234567890, 5) . "<br>";
|
print "S-FCEIL: " . $math_class::fceil(5.1234567890, 5) . "<br>";
|
||||||
print "S-FLOORP: " . $math_class::floorp(5123456, -3) . "<br>";
|
print "S-FLOORP: " . $math_class::floorp(5123456, -3) . "<br>";
|
||||||
|
print "S-FLOORP: " . $math_class::floorp(5123456, -10) . "<br>";
|
||||||
print "S-INITNUMERIC: " . $math_class::initNumeric(123) . "<br>";
|
print "S-INITNUMERIC: " . $math_class::initNumeric(123) . "<br>";
|
||||||
print "S-INITNUMERIC: " . $math_class::initNumeric(123.456) . "<br>";
|
print "S-INITNUMERIC: " . $math_class::initNumeric(123.456) . "<br>";
|
||||||
print "S-INITNUMERIC: " . $math_class::initNumeric('123') . "<br>";
|
print "S-INITNUMERIC: " . $math_class::initNumeric('123') . "<br>";
|
||||||
|
|||||||
@@ -1139,118 +1139,6 @@ class Basic
|
|||||||
|
|
||||||
// *** BETTER PASSWORD OPTIONS END ***
|
// *** BETTER PASSWORD OPTIONS END ***
|
||||||
|
|
||||||
// *** COLORS ***
|
|
||||||
// [!!! DEPRECATED !!!]
|
|
||||||
// moved to \CoreLibs\Convert\Colors
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts a hex RGB color to the int numbers
|
|
||||||
* @param string $hexStr RGB hexstring
|
|
||||||
* @param bool $returnAsString flag to return as string
|
|
||||||
* @param string $seperator string seperator: default: ","
|
|
||||||
* @return string|array<mixed>|bool false on error or array with RGB or
|
|
||||||
* a string with the seperator
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::hex2rgb() instead
|
|
||||||
*/
|
|
||||||
public static function hex2rgb(string $hexStr, bool $returnAsString = false, string $seperator = ',')
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hex2rgb()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::hex2rgb($hexStr, $returnAsString, $seperator);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts the rgb values from int data to the valid rgb html hex string
|
|
||||||
* optional can turn of leading #
|
|
||||||
* @param int $red red 0-255
|
|
||||||
* @param int $green green 0-255
|
|
||||||
* @param int $blue blue 0-255
|
|
||||||
* @param bool $hex_prefix default true, prefix with "#"
|
|
||||||
* @return string|bool rgb in hex values with leading # if set
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hex() instead
|
|
||||||
*/
|
|
||||||
public static function rgb2hex(int $red, int $green, int $blue, bool $hex_prefix = true)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hex()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::rgb2hex($red, $green, $blue, $hex_prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts and int RGB to the HTML color string in hex format
|
|
||||||
* @param int $red red 0-255
|
|
||||||
* @param int $green green 0-255
|
|
||||||
* @param int $blue blue 0-255
|
|
||||||
* @return string|bool hex rgb string
|
|
||||||
* @deprecated use rgb2hex instead
|
|
||||||
*/
|
|
||||||
public static function rgb2html(int $red, int $green, int $blue)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hex()', E_USER_DEPRECATED);
|
|
||||||
// check that each color is between 0 and 255
|
|
||||||
return \CoreLibs\Convert\Colors::rgb2hex($red, $green, $blue, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts RGB to HSB/V values
|
|
||||||
* returns:
|
|
||||||
* array with hue (0-360), sat (0-100%), brightness/value (0-100%)
|
|
||||||
* @param int $red red 0-255
|
|
||||||
* @param int $green green 0-255
|
|
||||||
* @param int $blue blue 0-255
|
|
||||||
* @return array<mixed>|bool Hue, Sat, Brightness/Value
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hsb() instead
|
|
||||||
*/
|
|
||||||
public static function rgb2hsb(int $red, int $green, int $blue)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hsb()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::rgb2hsb($red, $green, $blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts HSB/V to RGB values RGB is full INT
|
|
||||||
* @param int $H hue 0-360
|
|
||||||
* @param float $S saturation 0-1 (float)
|
|
||||||
* @param float $V brightness/value 0-1 (float)
|
|
||||||
* @return array<mixed>|bool 0 red/1 green/2 blue array
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::hsb2rgb() instead
|
|
||||||
*/
|
|
||||||
public static function hsb2rgb(int $H, float $S, float $V)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hsb2rgb()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::hsb2rgb($H, (int)round($S * 100), (int)round($V * 100));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts a RGB (0-255) to HSL
|
|
||||||
* return:
|
|
||||||
* array with hue (0-360), saturation (0-100%) and luminance (0-100%)
|
|
||||||
* @param int $r red 0-255
|
|
||||||
* @param int $g green 0-255
|
|
||||||
* @param int $b blue 0-255
|
|
||||||
* @return array<mixed>|bool hue/sat/luminance
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::rgb2hsl() instead
|
|
||||||
*/
|
|
||||||
public static function rgb2hsl(int $r, int $g, int $b)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hsl()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::rgb2hsb($r, $g, $b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* converts an HSL to RGB
|
|
||||||
* @param int $h hue: 0-360 (degrees)
|
|
||||||
* @param float $s saturation: 0-1
|
|
||||||
* @param float $l luminance: 0-1
|
|
||||||
* @return array<mixed>|bool red/blue/green 0-255 each
|
|
||||||
* @deprecated use \CoreLibs\Convert\Colors::hsl2rgb() instead
|
|
||||||
*/
|
|
||||||
public static function hsl2rgb(int $h, float $s, float $l)
|
|
||||||
{
|
|
||||||
trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hsl2rgb()', E_USER_DEPRECATED);
|
|
||||||
return \CoreLibs\Convert\Colors::hsl2rgb($h, $s * 100, $l * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// *** COLORS END ***
|
|
||||||
|
|
||||||
// *** EMAIL FUNCTIONS ***
|
// *** EMAIL FUNCTIONS ***
|
||||||
// [!!! DEPRECATED !!!]
|
// [!!! DEPRECATED !!!]
|
||||||
// Moved to \CoreLibs\Check\Email
|
// Moved to \CoreLibs\Check\Email
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ class CieXyz
|
|||||||
private static function linRgbToXyzD65(RGB $rgb): XYZ
|
private static function linRgbToXyzD65(RGB $rgb): XYZ
|
||||||
{
|
{
|
||||||
// if not linear, convert to linear
|
// if not linear, convert to linear
|
||||||
if (!$rgb->get('linear')) {
|
if (!(bool)$rgb->get('linear')) {
|
||||||
$rgb = (new RGB($rgb->returnAsArray()))->toLinear();
|
$rgb = (new RGB($rgb->returnAsArray()))->toLinear();
|
||||||
}
|
}
|
||||||
return new XYZ(self::convertArray(Math::multiplyMatrices(
|
return new XYZ(self::convertArray(Math::multiplyMatrices(
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class Colors
|
|||||||
* @param bool $hex_prefix default true, prefix with "#"
|
* @param bool $hex_prefix default true, prefix with "#"
|
||||||
* @return string rgb in hex values with leading # if set,
|
* @return string rgb in hex values with leading # if set,
|
||||||
* @throws \LengthException If any argument is not in the range of 0~255
|
* @throws \LengthException If any argument is not in the range of 0~255
|
||||||
|
* @deprecated v9.20.0 use: new Coordinates\RGB([$red, $green, $blue]))->returnAsHex(true/false for #)
|
||||||
*/
|
*/
|
||||||
public static function rgb2hex(
|
public static function rgb2hex(
|
||||||
int $red,
|
int $red,
|
||||||
@@ -53,6 +54,7 @@ class Colors
|
|||||||
* or a string with the seperator
|
* or a string with the seperator
|
||||||
* @throws \InvalidArgumentException if hex string is empty
|
* @throws \InvalidArgumentException if hex string is empty
|
||||||
* @throws \UnexpectedValueException if the hex string value is not valid
|
* @throws \UnexpectedValueException if the hex string value is not valid
|
||||||
|
* @deprecated v9.20.0 use: new Coordinates\RGB($hex_string) (build string/array from return data)
|
||||||
*/
|
*/
|
||||||
public static function hex2rgb(
|
public static function hex2rgb(
|
||||||
string $hex_string,
|
string $hex_string,
|
||||||
@@ -91,6 +93,7 @@ class Colors
|
|||||||
* @param int $blue blue 0-255
|
* @param int $blue blue 0-255
|
||||||
* @return array<int|float> Hue, Sat, Brightness/Value
|
* @return array<int|float> Hue, Sat, Brightness/Value
|
||||||
* @throws \LengthException If any argument is not in the range of 0~255
|
* @throws \LengthException If any argument is not in the range of 0~255
|
||||||
|
* @deprecated v9.20.0 use: Color::rgbToHsb(...)->returnAsArray() will return float unrounded
|
||||||
*/
|
*/
|
||||||
public static function rgb2hsb(int $red, int $green, int $blue): array
|
public static function rgb2hsb(int $red, int $green, int $blue): array
|
||||||
{
|
{
|
||||||
@@ -112,6 +115,7 @@ class Colors
|
|||||||
* @param float $V brightness/value 0-100 (int)
|
* @param float $V brightness/value 0-100 (int)
|
||||||
* @return array<int> 0 red/1 green/2 blue array as 0-255
|
* @return array<int> 0 red/1 green/2 blue array as 0-255
|
||||||
* @throws \LengthException If any argument is not in the valid range
|
* @throws \LengthException If any argument is not in the valid range
|
||||||
|
* @deprecated v9.20.0 use: Color::hsbToRgb(...)->returnAsArray() will return float unrounded
|
||||||
*/
|
*/
|
||||||
public static function hsb2rgb(float $H, float $S, float $V): array
|
public static function hsb2rgb(float $H, float $S, float $V): array
|
||||||
{
|
{
|
||||||
@@ -133,6 +137,7 @@ class Colors
|
|||||||
* @param int $blue blue 0-255
|
* @param int $blue blue 0-255
|
||||||
* @return array<float> hue/sat/luminance
|
* @return array<float> hue/sat/luminance
|
||||||
* @throws \LengthException If any argument is not in the range of 0~255
|
* @throws \LengthException If any argument is not in the range of 0~255
|
||||||
|
* @deprecated v9.20.0 use: Color::rgbToHsl(...)->returnAsArray() will return float unrounded
|
||||||
*/
|
*/
|
||||||
public static function rgb2hsl(int $red, int $green, int $blue): array
|
public static function rgb2hsl(int $red, int $green, int $blue): array
|
||||||
{
|
{
|
||||||
@@ -153,6 +158,7 @@ class Colors
|
|||||||
* @param float $lum luminance: 0-100
|
* @param float $lum luminance: 0-100
|
||||||
* @return array<int,float|int> red/blue/green 0-255 each
|
* @return array<int,float|int> red/blue/green 0-255 each
|
||||||
* @throws \LengthException If any argument is not in the valid range
|
* @throws \LengthException If any argument is not in the valid range
|
||||||
|
* @deprecated v9.20.0 use: Color::hslToRgb(...)->returnAsArray() will return float unrounded
|
||||||
*/
|
*/
|
||||||
public static function hsl2rgb(float $hue, float $sat, float $lum): array
|
public static function hsl2rgb(float $hue, float $sat, float $lum): array
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -136,6 +136,28 @@ class Math
|
|||||||
*
|
*
|
||||||
* It returns an array which is the product of the two number matrices passed as parameters.
|
* It returns an array which is the product of the two number matrices passed as parameters.
|
||||||
*
|
*
|
||||||
|
* NOTE:
|
||||||
|
* if the right side (B matrix) has a missing row, this row will be fillwed with 0 instead of
|
||||||
|
* throwing an error:
|
||||||
|
* A:
|
||||||
|
* [
|
||||||
|
* [1, 2, 3],
|
||||||
|
* [4, 5, 6],
|
||||||
|
* ]
|
||||||
|
* B:
|
||||||
|
* [
|
||||||
|
* [7, 8, 9],
|
||||||
|
* [10, 11, 12],
|
||||||
|
* ]
|
||||||
|
* The B will get a third row with [0, 0, 0] added to make the multiplication work as it will be
|
||||||
|
* rewritten as
|
||||||
|
* B-rewrite:
|
||||||
|
* [
|
||||||
|
* [7, 10, 0],
|
||||||
|
* [8, 11, 12],
|
||||||
|
* [0, 0, 0] <- automatically added
|
||||||
|
* ]
|
||||||
|
*
|
||||||
* @param array<float|int|array<int|float>> $a m x n matrice
|
* @param array<float|int|array<int|float>> $a m x n matrice
|
||||||
* @param array<float|int|array<int|float>> $b n x p matrice
|
* @param array<float|int|array<int|float>> $b n x p matrice
|
||||||
*
|
*
|
||||||
@@ -161,8 +183,9 @@ class Math
|
|||||||
$p = count($b[0]);
|
$p = count($b[0]);
|
||||||
|
|
||||||
// transpose $b:
|
// transpose $b:
|
||||||
|
// so that we can multiply row by row
|
||||||
$bCols = array_map(
|
$bCols = array_map(
|
||||||
callback: fn ($k) => \array_map(
|
callback: fn ($k) => array_map(
|
||||||
(fn ($i) => is_array($i) ? $i[$k] : 0),
|
(fn ($i) => is_array($i) ? $i[$k] : 0),
|
||||||
$b,
|
$b,
|
||||||
),
|
),
|
||||||
@@ -175,7 +198,8 @@ class Math
|
|||||||
array_reduce(
|
array_reduce(
|
||||||
array: $row,
|
array: $row,
|
||||||
callback: fn ($a, $v, $i = null) => $a + $v * (
|
callback: fn ($a, $v, $i = null) => $a + $v * (
|
||||||
$col[$i ?? array_search($v, $row) ?: 0]
|
// if last entry missing for full copy add a 0 to it
|
||||||
|
$col[$i ?? array_search($v, $row, true)] ?? 0 /** @phpstan-ignore-line */
|
||||||
),
|
),
|
||||||
initial: 0,
|
initial: 0,
|
||||||
) :
|
) :
|
||||||
@@ -191,7 +215,7 @@ class Math
|
|||||||
|
|
||||||
if ($m === 1) {
|
if ($m === 1) {
|
||||||
// Avoid [[a, b, c, ...]]:
|
// Avoid [[a, b, c, ...]]:
|
||||||
$product = $product[0];
|
return $product[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($p === 1) {
|
if ($p === 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user