-
-
Save vivi90/a9749fe1f8381b6083cea68b2e97f975 to your computer and use it in GitHub Desktop.
An SVG template for PHP which will render ReadMe badges
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 | |
$leftWidth = strlen($leftText) * 10; | |
$rightWidth = strlen($rightText) * 13 + 5; | |
$totalWidth = $leftWidth + $rightWidth - 5; | |
?> | |
<svg xmlns="http://www.w3.org/2000/svg" width="<?= $totalWidth ?>" height="20"> | |
<linearGradient id="smooth" x2="0" y2="100%"> | |
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/> | |
<stop offset="1" stop-opacity=".1"/> | |
</linearGradient> | |
<mask id="round"> | |
<rect width="<?= $totalWidth ?>" height="20" rx="4" fill="#fff"/> | |
</mask> | |
<g mask="url(#round)"> | |
<rect width="<?= $leftWidth ?>" height="20" fill="<?= $leftBackgroundColor ?>"/> | |
<rect x="<?= $leftWidth ?>" width="<?= $rightWidth ?>" height="20" fill="<?= $rightBackgroundColor ?>"/> | |
<rect width="<?= $totalWidth ?>" height="20" fill="url(#smooth)"/> | |
</g> | |
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="12"> | |
<text x="<?= $leftWidth / 2 + 1 ?>" y="15" fill="#010101" fill-opacity=".3"><?= $leftText ?></text> | |
<text x="<?= $leftWidth / 2 + 1 ?>" y="14" fill="<?= $leftTextColor ?>"><?= $leftText ?></text> | |
<text x="<?= $leftWidth + $rightWidth / 2.5 - 1 ?>" y="15" fill="#010101" fill-opacity=".3"><?= $rightText ?></text> | |
<text x="<?= $leftWidth + $rightWidth / 2.5 - 1 ?>" y="14" fill="<?= $rightTextColor ?>"><?= $rightText ?></text> | |
</g> | |
</svg> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment