Skip to content

Commit

Permalink
Merge pull request #4 from poissonconsulting/checkrtochk
Browse files Browse the repository at this point in the history
- Switch dependency from checkr to chk.
  • Loading branch information
sebdalgarno authored Mar 31, 2020
2 parents a46bb97 + 8daf7e5 commit b5a76ed
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Description: Generate a palette of tints, shades or both from a single colour.
URL: https://github.com/poissonconsulting/tinter
BugReports: https://github.com/poissonconsulting/tinter/issues
Imports:
checkr,
chk,
grDevices
Suggests:
graphics,
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
export(darken)
export(lighten)
export(tinter)
import(checkr)
import(chk)
2 changes: 1 addition & 1 deletion R/namespace.R
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#' @import checkr
#' @import chk
NULL
18 changes: 10 additions & 8 deletions R/tinter.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
#' tinter("#fa6a5c", direction = "tints")

tinter <- function(x, steps = 5, crop = 1, direction = "both", adjust = 0){

check_colour(x)
check_length(x, length = 1L)
steps <- check_noneg_int(steps, coerce = TRUE)
crop <- check_noneg_int(crop, coerce = TRUE)
check_vector(direction, values = c("shades", "tints", "both"))
check_vector(adjust, c(-1, 1))
chk_whole_number(steps)
chk_whole_number(crop)
chk_string(direction)
chk_subset(direction, c("shades", "tints", "both"))
chk_number(adjust)
chk_range(adjust, c(-1, 1))

if(crop > steps)
stop("crop cannot be greater than steps.", call. = FALSE)
Expand Down Expand Up @@ -58,7 +58,8 @@ tinter <- function(x, steps = 5, crop = 1, direction = "both", adjust = 0){

darken <- function(x, amount){
lapply(x, check_colour)
check_vector(amount, values = c(0, 1))
chk_number(amount)
chk_range(amount)
sapply(x, function(x){shade(x, 100, 0)[amount*100]}, USE.NAMES = FALSE)
}

Expand All @@ -74,7 +75,8 @@ darken <- function(x, amount){

lighten <- function(x, amount){
lapply(x, check_colour)
check_vector(amount, values = c(0, 1))
chk_number(amount)
chk_range(amount)

if(amount == 0){
amount <- 0.01
Expand Down
1 change: 1 addition & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tint <- function(x, steps, crop){
}

check_colour <- function(x){
chk_string(x)
res <- try(grDevices::col2rgb(x),silent = TRUE)
if(class(res) == "try-error")
stop(x, " is not a valid color", call. = FALSE)
Expand Down
20 changes: 9 additions & 11 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,20 @@ grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1:2, 1

## Installation

To install from CRAN
```
To install the latest release from [CRAN](https://cran.r-project.org)
```{r, eval=FALSE}
install.packages("tinter")
```

To install the latest development version from [GitHub](https://github.com/poissonconsulting/tinter)
```
install.packages("devtools")
devtools::install_github("poissonconsulting/err")
devtools::install_github("poissonconsulting/checkr")
devtools::install_github("poissonconsulting/tinter")
To install the developmental version from [GitHub](https://github.com/poissonconsulting/tinter)
```{r, eval=FALSE}
# install.packages("remotes")
remotes::install_github("poissonconsulting/tinter")
```

To install the latest development version from the Poisson drat [repository](https://github.com/poissonconsulting/drat)
```
install.packages("drat")
To install the latest developmental release from the Poisson drat [repository](https://github.com/poissonconsulting/drat)
```{r, eval=FALSE}
# install.packages("drat")
drat::addRepo("poissonconsulting")
install.packages("tinter")
```
Expand Down
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,24 +125,28 @@ grDevices::colorRampPalette(colors = c("white", "blue", "black"))(11)[-(c(1:2, 1

## Installation

To install from CRAN
To install the latest release from [CRAN](https://cran.r-project.org)

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

To install the latest development version from
To install the developmental version from
[GitHub](https://github.com/poissonconsulting/tinter)

install.packages("devtools")
devtools::install_github("poissonconsulting/err")
devtools::install_github("poissonconsulting/checkr")
devtools::install_github("poissonconsulting/tinter")
``` r
# install.packages("remotes")
remotes::install_github("poissonconsulting/tinter")
```

To install the latest development version from the Poisson drat
To install the latest developmental release from the Poisson drat
[repository](https://github.com/poissonconsulting/drat)

install.packages("drat")
drat::addRepo("poissonconsulting")
install.packages("tinter")
``` r
# install.packages("drat")
drat::addRepo("poissonconsulting")
install.packages("tinter")
```

## Contribution

Expand Down

0 comments on commit b5a76ed

Please sign in to comment.