Skip to content

Commit

Permalink
Added generate-badge.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Nov 18, 2024
1 parent c5ebdb7 commit 253dd88
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions scripts/generate-badge.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

# Usage example:
# ./generate-badge.sh '🏠' 'Text here' > mybadge.svg

readonly emoji=${1:?} text=${2:?} color_fg=${3:-fff} color_bg=${4:-555}

readonly width=$((32 + ${#text} * 6))

cat << EOF
<svg xmlns="http://www.w3.org/2000/svg" width="$width" height="20">
<rect width="$width" height="20" fill="#$color_bg"/>
<text x="4" y="14" fill="#$color_fg" font-family="Consolas,monospace" font-size="11">$emoji $text</text>
</svg>
EOF

0 comments on commit 253dd88

Please sign in to comment.