Type: | Package |
Title: | Fast and Simple Badge Generator |
Version: | 1.0.1 |
Description: | Bindings to 'badgen' https://www.npmjs.com/package/badgen to generate beautiful 'svg' badges in R without internet access. Images can be converted to 'png' using the 'rsvg' package as shown in examples. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
BugReports: | https://github.com/jeroen/badgen/issues |
URL: | https://jeroen.r-universe.dev/badgen |
Imports: | jsonlite, V8 |
Suggests: | rsvg |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2024-10-03 14:12:11 UTC; jeroen |
Author: | Jeroen Ooms |
Maintainer: | Jeroen Ooms <jeroenooms@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-10-04 09:20:02 UTC |
Generate badges
Description
Generate a badge in the form of an svg string. Svg files can embedded directly in websites or converted to png as shown in examples.
Usage
badgen(
label,
status = "v1.2.3",
color = "green",
labelColor = "555",
style = "classic",
scale = 1,
svg_icon = NULL
)
Arguments
label |
text for left part of the badge |
status |
text for right part of the badge |
color |
background for status part |
labelColor |
background for label part |
style |
one of 'classic' or 'flat' |
scale |
resize badge, default size is 1 |
svg_icon |
iteral svg string with icon, see examples |
Value
svg string with the badge
Examples
home <- setwd(tempdir())
svg <- badgen("yolo", "success!", style = 'flat')
writeLines(svg, 'test.svg')
browseURL('test.svg')
# Convert svg to bitmap
rsvg::rsvg_png('test.svg', 'test.png')
# Add an svg icon to the badge
rlogo <- readLines('https://www.r-project.org/logo/Rlogo.svg')
svg2 <- badgen('mypkg', 'awesome', scale = 4, svg_icon = rlogo)
writeLines(svg2, 'test2.svg')
browseURL('test2.svg')
# Cleanup
Sys.sleep(1)
unlink(c('test.svg', 'test.png', 'test2.svg'))
setwd(home)