Last active
March 24, 2021 21:35
-
-
Save futuri/1f0134a1f91a02ac4fda7cc3573408fe to your computer and use it in GitHub Desktop.
Modificar a coordenas absolutas svg para usarlos en clippath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$absolute_path = "m 867.66051,733.90902 c 7.58365,-0.58723 13.51927,-6.41546 14.24575,-13.97891 22.85162,-240.14627 25.36563,-451.48674 0,-687.860731 -0.72649,-7.563468 -6.66118,-13.390858 -14.24575,-13.97891 -287.85559,-22.0767539 -550.63525,-26.0815249 -835.319853,0 -7.585418,0.588113 -13.52008,6.41546 -14.246568,13.97891 -22.8516209,240.146271 -25.3665348,451.486731 0,687.860731 0.726498,7.56347 6.662072,13.39258 14.246568,13.97891 287.842933,22.08199 550.635253,26.07801 835.319853,0 z"; | |
function regex_callback($matches) { | |
static $count = -1; | |
$count++; | |
$width = 900; | |
$height = 752; | |
if($count % 2) { | |
return $matches[0] / $height; | |
} else { | |
return $matches[0] / $width; | |
} | |
} | |
$relative_path = preg_replace_callback('(\d+(\.\d+)?)', 'regex_callback', $absolute_path); | |
?> | |
<svg height="0" width="0" xmlns="http://www.w3.org/2000/svg"> | |
<defs> | |
<clipPath id="example" clipPathUnits="objectBoundingBox"> | |
<path d="<?php echo $relative_path; ?>"></path> | |
</clipPath> | |
</defs> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment