R/geom_icon.R

Defines functions list.icon icon geom_icon

Documented in geom_icon list.icon

##' geom layer for using icon
##'
##'
##' @title geom_icon
##' @inheritParams geom_pokemon
##' @return ggplot2 layer
##' @export
##' @author guangchuang yu
geom_icon <- function(mapping = NULL, data = NULL, inherit.aes = TRUE,
                      na.rm = FALSE, by = "width", ...) {
    geom_image(mapping, data, inherit.aes=inherit.aes, na.rm=na.rm, ..., .fun = icon)
}

icon <- function(id) {
    ## paste0('https://raw.githubusercontent.com/ionic-team/ionicons/master/src/svg/', id, '.svg')
    url <- paste0('https://ionicons.com/ionicons/svg/', id, '.svg')

    check_url(url)
}

##' list available icon
##'
##'
##' @title list.icon
##' @return icon vector
##' @export
##' @author guangchuang yu
list.icon <- function() {
    list.png("https://github.com/ionic-team/ionicons/tree/master/src/svg")
}

Try the ggimage package in your browser

Any scripts or data that you put into this service are public.

ggimage documentation built on July 9, 2023, 6:24 p.m.