diff --git a/DESCRIPTION b/DESCRIPTION index 6047550..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, 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 59e7fb6..28fa93d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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") ``` diff --git a/README.md b/README.md index cff8b9a..36a7976 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