|
@@ 459-479 (lines=21) @@
|
| 456 |
|
* @param $background_color |
| 457 |
|
* @return bool|string |
| 458 |
|
*/ |
| 459 |
|
function svg_ajouter_background($img, $background_color) { |
| 460 |
|
if ($svg = svg_charger($img) |
| 461 |
|
and $svg_infos = svg_lire_balise_svg($svg)){ |
| 462 |
|
|
| 463 |
|
if ($background_color and $background_color!=='transparent') { |
| 464 |
|
list($balise_svg, $attributs) = $svg_infos; |
| 465 |
|
|
| 466 |
|
$background_color = svg_couleur_to_hexa($background_color); |
| 467 |
|
if (isset($attributs['viewBox'])) { |
| 468 |
|
$viewBox = explode(' ', $attributs['viewBox']); |
| 469 |
|
$rect = "<rect x=\"".$viewBox[0]."\" y=\"".$viewBox[1]."\" width=\"".$viewBox[2]."\" height=\"".$viewBox[3]."\" fill=\"$background_color\"/>"; |
| 470 |
|
} |
| 471 |
|
else { |
| 472 |
|
$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>"; |
| 473 |
|
} |
| 474 |
|
$svg = svg_insert_shapes($svg, $rect); |
| 475 |
|
} |
| 476 |
|
return $svg; |
| 477 |
|
} |
| 478 |
|
return $img; |
| 479 |
|
} |
| 480 |
|
|
| 481 |
|
|
| 482 |
|
/** |
|
@@ 488-508 (lines=21) @@
|
| 485 |
|
* @param $background_color |
| 486 |
|
* @return bool|string |
| 487 |
|
*/ |
| 488 |
|
function svg_ajouter_voile($img, $background_color, $opacity) { |
| 489 |
|
if ($svg = svg_charger($img) |
| 490 |
|
and $svg_infos = svg_lire_balise_svg($svg)){ |
| 491 |
|
|
| 492 |
|
if ($background_color and $background_color!=='transparent') { |
| 493 |
|
list($balise_svg, $attributs) = $svg_infos; |
| 494 |
|
|
| 495 |
|
$background_color = svg_couleur_to_hexa($background_color); |
| 496 |
|
if (isset($attributs['viewBox'])) { |
| 497 |
|
$viewBox = explode(' ', $attributs['viewBox']); |
| 498 |
|
$rect = "<rect x=\"".$viewBox[0]."\" y=\"".$viewBox[1]."\" width=\"".$viewBox[2]."\" height=\"".$viewBox[3]."\" fill=\"$background_color\" opacity=\"$opacity\"/>"; |
| 499 |
|
} |
| 500 |
|
else { |
| 501 |
|
$rect = "<rect width=\"100%\" height=\"100%\" fill=\"$background_color\"/>"; |
| 502 |
|
} |
| 503 |
|
$svg = svg_insert_shapes($svg, $rect, false); |
| 504 |
|
} |
| 505 |
|
return $svg; |
| 506 |
|
} |
| 507 |
|
return $img; |
| 508 |
|
} |
| 509 |
|
|
| 510 |
|
|
| 511 |
|
/** |