diff --git a/DESCRIPTION b/DESCRIPTION index 7d52b1c..b53d71f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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, @@ -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 diff --git a/NAMESPACE b/NAMESPACE index c1d6355..06d81d3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,4 +3,4 @@ export(darken) export(lighten) export(tinter) -import(checkr) +import(chk) diff --git a/R/namespace.R b/R/namespace.R index cf772bd..33ffad1 100644 --- a/R/namespace.R +++ b/R/namespace.R @@ -1,2 +1,2 @@ -#' @import checkr +#' @import chk NULL diff --git a/R/tinter.R b/R/tinter.R index 54686f9..2082fd4 100644 --- a/R/tinter.R +++ b/R/tinter.R @@ -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) @@ -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) } @@ -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 diff --git a/R/utils.R b/R/utils.R index 20806fb..ce65fc4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -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) diff --git a/README.Rmd b/README.Rmd index 1e23a62..7bac506 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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") ``` diff --git a/README.md b/README.md index d1f9bd2..cf80dca 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_files/figure-gfm/colour-1.png b/README_files/figure-gfm/colour-1.png index cf05fb0..a46cabc 100644 Binary files a/README_files/figure-gfm/colour-1.png and b/README_files/figure-gfm/colour-1.png differ diff --git a/README_files/figure-gfm/crop-1.png b/README_files/figure-gfm/crop-1.png index 73bd668..0c96a8c 100644 Binary files a/README_files/figure-gfm/crop-1.png and b/README_files/figure-gfm/crop-1.png differ diff --git a/README_files/figure-gfm/darken-1.png b/README_files/figure-gfm/darken-1.png index cf39edc..2e3dc9f 100644 Binary files a/README_files/figure-gfm/darken-1.png and b/README_files/figure-gfm/darken-1.png differ diff --git a/README_files/figure-gfm/plot-1.png b/README_files/figure-gfm/plot-1.png index 1e45e59..0e90a61 100644 Binary files a/README_files/figure-gfm/plot-1.png and b/README_files/figure-gfm/plot-1.png differ diff --git a/README_files/figure-gfm/steps-1.png b/README_files/figure-gfm/steps-1.png index 4b8ceb1..3bbb89b 100644 Binary files a/README_files/figure-gfm/steps-1.png and b/README_files/figure-gfm/steps-1.png differ diff --git a/README_files/figure-gfm/tinter-1.png b/README_files/figure-gfm/tinter-1.png index 7b44656..16e0806 100644 Binary files a/README_files/figure-gfm/tinter-1.png and b/README_files/figure-gfm/tinter-1.png differ diff --git a/README_files/figure-gfm/tints-1.png b/README_files/figure-gfm/tints-1.png index 9b5068a..93feb55 100644 Binary files a/README_files/figure-gfm/tints-1.png and b/README_files/figure-gfm/tints-1.png differ