Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/EmilHvitfeldt/prismatic

color manipulation R package Simply and Tidy
https://github.com/EmilHvitfeldt/prismatic

color color-manipulation colour r rstats

Last synced: 3 months ago
JSON representation

color manipulation R package Simply and Tidy

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r opts, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# prismatic

[![R-CMD-check](https://github.com/EmilHvitfeldt/prismatic/workflows/R-CMD-check/badge.svg)](https://github.com/EmilHvitfeldt/prismatic/actions)
[![Codecov test coverage](https://codecov.io/gh/EmilHvitfeldt/prismatic/branch/main/graph/badge.svg)](https://app.codecov.io/gh/EmilHvitfeldt/prismatic?branch=main)
[![CRAN status](http://www.r-pkg.org/badges/version/prismatic)](https://CRAN.R-project.org/package=prismatic)
[![Downloads](http://cranlogs.r-pkg.org/badges/prismatic)](https://CRAN.R-project.org/package=prismatic)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![DOI](https://zenodo.org/badge/205078698.svg)](https://zenodo.org/record/4420786)

The goal of prismatic is to provide color manipulation tools in R, in a intuitive, low-dependency and functional way.

- **intuitive** All the working functions are prefixed with `clr_` (**c**o**l**o**r**) allowing for easy autocompletion.
- **low-dependency** Only depends on [farver](https://github.com/thomasp85/farver).
- **functional** All functions have consistent inputs and outputs and are thus fully pipeable.

## Installation

You can install the released version of prismatic from [CRAN](https://CRAN.R-project.org) with:

``` r
install.packages("prismatic")
```

And the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("EmilHvitfeldt/prismatic")
```
## Examples

All **prismatic** functions returns a `colors` object, which includes a new printing method and plotting method for quickly visualizing the colors.

```{r terraincols, dpi=320}
library(prismatic)
library(magrittr)

terrain10 <- terrain.colors(10)

terrain10

terrain_color <- color(terrain10)

terrain_color

plot(terrain_color)
```

If [cli](https://github.com/r-lib/cli) is available the print method will do its best to represent the colors.

![](man/figures/sceenshot.png)

```{r plotcols, dpi=320}
library(prismatic)
library(magrittr)
ddd <- color(terrain.colors(10))

ddd

plot(ddd)
clr_grayscale(ddd) %>% plot()
clr_lighten(ddd, 0.7) %>% plot()
clr_darken(ddd, 0.5) %>% plot()
clr_saturate(ddd, 0.5) %>% plot()
clr_desaturate(ddd, 0.5) %>% plot()
clr_negate(ddd) %>% plot()
clr_rotate(ddd, 180) %>% plot()

clr_protan(ddd) %>% plot()
clr_tritan(ddd) %>% plot()
clr_deutan(ddd) %>% plot()
```

## Related work

This package is hugely inspired by the JavaScript library [Qix-/color](https://github.com/Qix-/color).

## Code of Conduct

Please note that the 'prismatic' project is released with a [Contributor Code of Conduct](https://github.com/EmilHvitfeldt/prismatic/blob/main/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.