Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrbrmstr/swatches
π¨ Read, Inspect, Manipulate, and Save (ASE-only for save) Color Swatch Files
https://github.com/hrbrmstr/swatches
aco ase rstats rstats-package swatch swatches
Last synced: 7 days ago
JSON representation
π¨ Read, Inspect, Manipulate, and Save (ASE-only for save) Color Swatch Files
- Host: GitHub
- URL: https://github.com/hrbrmstr/swatches
- Owner: hrbrmstr
- License: other
- Created: 2015-03-21T16:35:28.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-04-02T15:03:21.000Z (over 2 years ago)
- Last Synced: 2024-10-12T21:23:32.223Z (22 days ago)
- Topics: aco, ase, rstats, rstats-package, swatch, swatches
- Language: R
- Homepage:
- Size: 661 KB
- Stars: 56
- Watchers: 7
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/swatches)](https://cran.r-project.org/package=swatches)
[![Build Status](https://travis-ci.org/hrbrmstr/swatches.svg)](https://travis-ci.org/hrbrmstr/swatches)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/hrbrmstr/swatches?branch=master&svg=true)](https://ci.appveyor.com/project/hrbrmstr/swatches)
[![Coverage Status](https://img.shields.io/codecov/c/github/hrbrmstr/swatches/master.svg)](https://codecov.io/github/hrbrmstr/swatches?branch=master)
[![](http://cranlogs.r-pkg.org/badges/swatches)](http://cran.rstudio.com/web/packages/swatches/index.html)# swatches
Read, Inspect, Manipulate, and Save (ASE) Color Swatch Files (ACO/ASE/GPL/SOC/KDE/COLORS)
## Description
In _Envisioning Information_, Edward Tufte says _"β¦avoiding catastrophe becomes the first principle in bringing color to information: Above all, do no harm."_ R users gain a quick upper hand in adhering to this "do no harm" thanks to sane defaults in `ggplot2` and packages like `viridis`, `ggthemes` or `RColorBrewer` that enable use of established and good color palettes.
If you do visualization work in conjunction with a design shop or organization that establishes their own palettes and themes there will often be standard palettes that must be adhered to. These are usually stored and shared in some type of Adobe swatch file format. There are also many sites like [Adobe Color CC](https://color.adobe.com/) and [COLOUR Lovers](https://www.colourlovers.com/) where folks can create and share color palettes. Plus, there are thousands of other palette files in dozens of palette formates.
This package enables you to use the colors straight from `.ase`, `.aso`, `.gpl`, `.soc` or `.color` files and avoid the cutting/pasting of hex codes or using color pickers to extract the color information. You can read these swatch files directly from the internet and/or include the files directly in your R projects. This will make it easier to modify a resource versus change code.
NOTE that just beacuse an ASE, ACO, GPL, SOC or color file exists on the internet does _not_ mean that it will let you "do no harm". You still need to use good judgement from knowledge/experience (or advice from experts) to ensure you are using colors effectively. This package just opens up the world of colors in R a little bit more.
## What's Inside The Tin
The following functions are implemented:
- `read_palette`: Generic function to read any supported palette type (determined by extension)
- `read_aco`: Read colors from Adobe Color (ACO) files
- `read_ase`: Read colors from Adobe Swatch Exchange (ASE) files
- `read_gpl`: Read GIMP Palette (GPL) files
- `read_soc`: Read OpenOffice palette (SOC) files
- `read_kde`: Read KDE Palette (colors) files
- `show_palette`: Display a color palette
- `add_color`: Add a named color to an ASE swatch object
- `ase_encode`: Encode a built ASE object for output
- `create_ase`: Create an ASE object
- `hex_to_ase`: Convert a list of named, hexadecimal RBG colors into an ASE object### TODO
- ACO/ASE Grayscale support (just need to find or gen Grayscale ASE/ACO files, if you have a few please hook me up)
- ACO/ASE LAB support (could use some help with this)
- Writing out palette files (somewhat done!)## Installation
```{r eval=FALSE}
devtools::install_github("hrbrmstr/swatches")
``````{r echo=FALSE, message=FALSE, warning=FALSE, error=FALSE}
options(width=80)
```## Usage & Exposition
```{r}
library(swatches)# current verison
packageVersion("swatches")```
One good source for palettes is the ["Most Popular" section](https://color.adobe.com/explore/most-popular/?time=all) on Adobe Color CC. If you use the Adobe ecosystem, you can sync ASE palette files directly locally or download them directly (registration required).
![](img/adobe01.png)
The "Herbs and Spice" and "Keep the Change" palettes are kinda nifty, and also included in this package (since Adobe has yet to release the new API for the color site for automatic downloading). We can take a quick look at both of them. Here they are from the web site:
![](img/hns.png)
![](img/ktc.png)
And, there they are via this package:
```{r fig.height=2.5}
herbs_and_spice <- read_ase(system.file("palettes", "herbs_and_spice.ase", package="swatches"))
print(herbs_and_spice)
show_palette(herbs_and_spice)
``````{r fig.height=2.5}
keep_the_change <- read_ase(system.file("palettes", "keep_the_change.ase", package="swatches"))
print(keep_the_change)
show_palette(keep_the_change)
```As said earlier, you can also read directly from a URL. Here is a "metal" palette ripped straight [from github](https://github.com/picwellwisher12pk/en_us/):
```{r fig.height=2.5}
metal <- read_ase("https://github.com/picwellwisher12pk/en_us/raw/master/Swatches/Metal.ase")
print(metal)
show_palette(metal)
```As you can see, this "metal" palette actually had named colors (albeit bland, CMYK value names).
Some palettes, like the Omega Nebula (CC-BY-SA [davidgav](http://www.colourlovers.com/lover/davidgav/loveNote)) one included with the package, have license restrictions (the mind _boggles_), so be aware of that when blatantly using others' designs without attribution. David's palette has much better names:
```{r fig.height=2.5}
omega_nebula <- read_ase(system.file("palettes", "omega_nebula.ase", package="swatches"))
print(omega_nebula)
show_palette(omega_nebula)
```You need to use `unname` (or `use_names=FALSE` in `read_ase` or `read_aco`) before using them as `values`:
```{r fig.height=4}
library(ggplot2)
gg <- ggplot(mtcars, aes(x=mpg, y=disp))
gg <- gg + geom_point(aes(col=factor(gear)), size=3)
gg <- gg + scale_color_manual(values=unname(keep_the_change))
gg <- gg + theme_bw()
gg
```## Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.