parfum/app/Helpers/ColorHelpers.php

35 lines
911 B
PHP

<?php
if (! function_exists('generateRandomRgbaColors')) {
/**
* Generate an array of random RGBA colors
*
* @param int $count Number of colors to generate
* @param float $alpha Alpha/transparency value (default: 0.2)
*/
function generateRandomRgbaColors(int $count, float $alpha = 0.2): array
{
$colors = [];
for ($i = 0; $i < $count; $i++) {
$r = rand(0, 255);
$g = rand(0, 255);
$b = rand(0, 255);
$colors[] = "rgba($r, $g, $b, $alpha)";
}
return $colors;
}
}
if (! function_exists('randomBorderColors')) {
/**
* Generate an array of random RGB colors for borders (alpha = 1.0)
*
* @param int $count Number of colors to generate
*/
function randomBorderColors(int $count): array
{
return generateRandomRgbaColors($count, 1.0);
}
}