Browse Source

bug fix

master
Bob Rudis 9 years ago
parent
commit
a7f5a5cb5a
  1. 4
      DESCRIPTION
  2. 4
      NAMESPACE
  3. 2
      R/readpal.R
  4. 15
      R/soc.R
  5. 5
      R/swatches-package.R
  6. 0
      inst/palettes/ccooo.soc
  7. 10
      man/read_soc.Rd

4
DESCRIPTION

@ -1,7 +1,7 @@
Package: swatches
Type: Package
Title: Read and Visualize Color Swatch Files
Version: 0.3
Version: 0.3.1
Date: 2015-03-23
Author: Bob Rudis (@hrbrmstr)
Maintainer: Bob Rudis <bob@rudis.net>
@ -20,7 +20,7 @@ Description: There are numerous places to create and download color
URL: http://github.com/hrbrmstr/swatches
BugReports: https://github.com/hrbrmstr/swatches/issues
License: MIT + file LICENSE
NeedsCompilation: Yes
NeedsCompilation: yes
Imports:
httr (>= 0.6.0),
pack,

4
NAMESPACE

@ -7,11 +7,9 @@ export(read_kde)
export(read_palette)
export(read_soc)
export(show_palette)
import(XML)
import(pack)
import(stringr)
importFrom(XML,xmlAttrs)
importFrom(XML,xmlParse)
importFrom(XML,xpathSApply)
importFrom(httr,GET)
importFrom(httr,stop_for_status)
importFrom(httr,write_disk)

2
R/readpal.R

@ -18,8 +18,8 @@ read_palette <- function(path, use_names=TRUE, .verbose=FALSE) {
if (ext == "aco") { return(read_aco(path, use_names, .verbose)) }
if (ext == "ase") { return(read_ase(path, use_names, .verbose)) }
if (ext == "gpl") { return(read_gpl(path, use_names, .verbose)) }
if (ext == "kde") { return(read_kde(path, use_names, .verbose)) }
if (ext == "soc") { return(read_soc(path, use_names, .verbose)) }
if (ext == "colors") { return(read_kde(path, use_names, .verbose)) }
message("Unrecognized or unsupported palette file format")

15
R/soc.R

@ -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)]

5
R/swatches-package.R

@ -1,11 +1,8 @@
#' Read color/swatch files
#' @name swatches
#' @docType package
#' @import pack stringr
#' @import pack stringr XML
#' @importFrom tools file_ext
#' @importFrom XML xmlParse
#' @importFrom XML xpathSApply
#' @importFrom XML xmlAttrs
#' @importFrom httr write_disk
#' @importFrom httr GET
#' @importFrom httr stop_for_status

0
inst/palettes/cc-ooo.soc → inst/palettes/ccooo.soc

10
man/read_soc.Rd

@ -2,7 +2,7 @@
% Please edit documentation in R/soc.R
\name{read_soc}
\alias{read_soc}
\title{#Read colors from OpenOffice Palette (SOC) files}
\title{Read colors from OpenOffice Palette (SOC) files}
\usage{
read_soc(path, use_names = TRUE, .verbose = FALSE)
}
@ -20,13 +20,13 @@ a named character vector (if color names are present) of hex RGB colors.
\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.
}
\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)

Loading…
Cancel
Save