Skip to content

Commit

Permalink
- Switch dependency from checkr to chk.
Browse files Browse the repository at this point in the history
  • Loading branch information
joethorley committed Mar 31, 2020
1 parent 1f93088 commit 82add10
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 34 deletions.
4 changes: 2 additions & 2 deletions 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 All @@ -17,5 +17,5 @@ Suggests:
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
Language: en-US
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 @@ -147,22 +147,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
Binary file modified README_files/figure-gfm/colour-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/crop-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/darken-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/steps-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/tinter-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_files/figure-gfm/tints-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 82add10

Please sign in to comment.