forked from EmilHvitfeldt/prismatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
93 lines (66 loc) · 3.01 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r opts, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# prismatic <img src='man/figures/logo.png' height="139" style="float:right" />
<!-- badges: start -->
[![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)
<!-- badges: end -->
The goal of prismatic is to provide color manipulation tools in R, in an 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** function return a `colors` object, which includes a new printing method and plotting method for quickly visualizing the colors.
```{r terraincols, dpi=320}
library(prismatic)
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}
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.