|
|
@ -1,7 +1,4 @@ |
|
|
|
# |
|
|
|
# # cc-ooo.soc |
|
|
|
# |
|
|
|
# #' Read colors from OpenOffice Palette (SOC) files |
|
|
|
#' Read colors from OpenOffice Palette (SOC) files |
|
|
|
#' |
|
|
|
#' Given a path or URL to an \code{.soc} file, this function will return |
|
|
|
#' a named character vector (if color names are present) of hex RGB colors. |
|
|
@ -11,13 +8,13 @@ |
|
|
|
#' @param .verbose show extra information about GPL file processing |
|
|
|
#' @note When using named color palettes in a \code{ggplot2} \code{scale_} context, you |
|
|
|
#' must \code{unname} them or set \code{use_names} to \code{FALSE}. |
|
|
|
#' Not sure if this is a bug or a deliberate feature in ggplot2. Also, Neither Lab nor |
|
|
|
#' greyscale colors are supported. |
|
|
|
#' Not sure if this is a bug or a deliberate feature in ggplot2. |
|
|
|
#' @export |
|
|
|
#' @examples |
|
|
|
#' # built-in palette |
|
|
|
#' ccooo <- read_soc(system.file("palettes", |
|
|
|
#' "cc-ooo.soc", package="swatches")) |
|
|
|
#' soc_file <- system.file("palettes", "ccooo.soc", package="swatches") |
|
|
|
#' system(sprintf("cat %s", soc_file)) |
|
|
|
#' ccooo <- read_soc(soc_file) |
|
|
|
#' print(ccooo) |
|
|
|
#' #show_palette(ccooo) |
|
|
|
#' |
|
|
@ -35,7 +32,7 @@ read_soc <- function(path, use_names=TRUE, .verbose=FALSE) { |
|
|
|
|
|
|
|
pal <- NULL |
|
|
|
|
|
|
|
soc <- xmlParse("inst/palettes/cc-ooo.soc") |
|
|
|
soc <- xmlParse(path) |
|
|
|
tmp <- gsub("^\ +", "", xpathSApply(soc, "//draw:color", xmlAttrs, "draw:name")) |
|
|
|
pal <- tmp[seq(2, length(tmp), 2)] |
|
|
|
names(pal) <- tmp[seq(1, length(tmp), 2)] |
|
|
|