I want to dynamically change the color of the SVG depending on which background color is selected. This works, but it will not work as a background image, as the .php file name
Here is my PHP code that makes my image, I did not include all the paths:
<?php
header('Content-type: image/svg+xml');
function adjustBridgtness($rgb, $steps) {
if (count($rgb) == 3) {
$steps = max(-255, min(255, $steps));
$new_color = array();
foreach($rgb as $color) {
$color = max(0,min(255,$color + $steps));
$new_color[] = $color;
}
return $new_color;
}
}
$colors[0] = adjustBridgtness(array(67,189,151),0);
$colors[1] = array(81,193,159);
$colors[2] = array(95,199,165);
$colors[3] = array(107,203,173);
$colors[4] = array(127,211,185);
$colors[5] = array(81,193,159);
$colors[6] = array(127,211,185);
?>
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="796px" height="404px" viewBox="0 0 796 404">
<path fillRule="evenodd" d="M 349.5 153.12C 349.5 153.12 396.88 200.5 396.88 200.5 396.88 200.5 349.5 247.88 349.5 247.88 349.5 247.88 302.12 200.5 302.12 200.5 302.12 200.5 349.5 153.12 349.5 153.12Z" fill="rgb(<?=$colors[0][0]?>,<?=$colors[0][1]?>,<?=$colors[0][2]?>)"/>
<path fillRule="evenodd" d="M 251.5 153.12C 251.5 153.12 298.88 200.5 298.88 200.5 298.88 200.5 251.5 247.88 251.5 247.88 251.5 247.88 204.12 200.5 204.12 200.5 204.12 200.5 251.5 153.12 251.5 153.12Z" fill="rgb(<?=$colors[0][0]?>,<?=$colors[0][1]?>,<?=$colors[0][2]?>)"/>
</svg>
I just put it in the background-image property like this:
background-image:url(images/image.php);
This does not work though, since it does not appear, what did I do wrong?
PS Only the website administrator can change the background color, would it be better to generate an SVG and overwrite the existing file, for example background.svg, when the color is changed, and not generate colors every time the page is loaded?