R/create_palette.R

Defines functions create_palette

Documented in create_palette

# NOTE: this is autogenerated -- do not edit by
# hand
#' create palette for colorpile
#'
#' @title Create palette for colorpile
#' @param name The short name of the colour scheme
#' @param authors vector of name(s) of palette author(s)
#' @param colors Vector of colors, each in hex format
#' @param type One of 'diverging', 'qualitative', 'sequential', 'other'
#' @param github_user The GitHub username of the palette's author (or primary author if there is more than one name in authors)
#' @param description A description, possibly longer than the name
#' @param keywords Vector of palette keywords
#' @param date Date scheme was created or modified
#'
#' @export
create_palette <- function(name, authors, colors, type,
    github_user = NULL, description = NULL, keywords = NULL,
    date = Sys.Date()) {
    palette_data <- drop_null(list(name = jsonlite::unbox(name),
        authors = authors, colors = colors, type = jsonlite::unbox(type),
        github_user = jsonlite::unbox(github_user),
        description = jsonlite::unbox(description),
        keywords = keywords, date = jsonlite::unbox(date)))
    palette_str <- jsonlite::toJSON(palette_data, pretty = TRUE)
    write(palette_str, file = sprintf("%s.json", name))
}
ropenscilabs/colorpiler documentation built on May 18, 2022, 7:35 p.m.