diff --git a/DESCRIPTION b/DESCRIPTION index a0d78b1..3fcba46 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: RCDT Title: Fast 2D Constrained Delaunay Triangulation -Version: 1.2.1 +Version: 1.2.1.9000 Authors@R: c( person("Stéphane", "Laurent", , "laurent_step@outlook.fr", role = c("aut", "cre")), person("Artem", "Amirkhanov", role = "cph", @@ -16,9 +16,10 @@ License: GPL-3 URL: https://github.com/stla/RCDT BugReports: https://github.com/stla/RCDT/issues Imports: + colorsGen, gplots, graphics, - randomcoloR, + Polychrome, Rcpp (>= 1.0.8), rgl, Rvcg @@ -32,9 +33,9 @@ LinkingTo: BH, Rcpp, RcppArmadillo -SystemRequirements: C++ 14 +SystemRequirements: C++ 17 VignetteBuilder: knitr Config/testthat/edition: 3 Encoding: UTF-8 -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index 792e01c..7598be1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,14 +3,14 @@ export(delaunay) export(delaunayArea) export(plotDelaunay) +importFrom(Polychrome,createPalette) importFrom(Rcpp,evalCpp) importFrom(Rvcg,vcgGetEdge) +importFrom(colorsGen,randomColor) importFrom(gplots,col2hex) importFrom(graphics,par) importFrom(graphics,plot) importFrom(graphics,polygon) importFrom(graphics,segments) -importFrom(randomcoloR,distinctColorPalette) -importFrom(randomcoloR,randomColor) importFrom(rgl,tmesh3d) useDynLib(RCDT, .registration=TRUE) diff --git a/NEWS.md b/NEWS.md index 4e77beb..be5970e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# RCDT 1.3.0 (2023-10-31) + +The package does no longer depend on 'randomcoloR', but it now depends on +'colorsGen' and 'Polychrome'. + + # RCDT 1.2.1 (2022-08-13) * Skip a unit test on Mac; it fails for some reason. diff --git a/R/colors.R b/R/colors.R new file mode 100644 index 0000000..733cc1c --- /dev/null +++ b/R/colors.R @@ -0,0 +1,16 @@ +#' @importFrom Polychrome createPalette +#' @noRd +distinctColors <- function(n, argsList) { + f <- function(...) { + createPalette(n, ...) + } + do.call(f, argsList) +} + +#' @importFrom colorsGen randomColor +rcolors <- function(n, argsList) { + f <- function(...) { + randomColor(n, ...) + } + do.call(f, argsList) +} diff --git a/R/plot.R b/R/plot.R index bd434ba..3f02edb 100644 --- a/R/plot.R +++ b/R/plot.R @@ -13,13 +13,15 @@ #' \code{NULL} for no color #' @param fillcolor controls the filling colors of the triangles, either #' \code{NULL} for no color, a single color, \code{"random"} to get multiple -#' colors with \code{\link[randomcoloR]{randomColor}}, \code{"distinct"} -#' get multiple colors with \code{\link[randomcoloR]{distinctColorPalette}}, +#' colors with \code{\link[colorsGen]{randomColor}}, \code{"distinct"} +#' get multiple colors with \code{\link[Polychrome]{createPalette}}, #' or a vector of colors, one color for each triangle; in this case the #' the colors will be assigned in the order they are provided but after the #' triangles have been circularly ordered (see the last example) -#' @param hue,luminosity if \code{color = "random"}, these arguments are passed -#' to \code{\link[randomcoloR]{randomColor}} +#' @param distinctArgs if \code{fillcolor = "distinct"}, a list of arguments +#' passed to \code{\link[Polychrome]{createPalette}} +#' @param randomArgs if \code{fillcolor = "random"}, a list of arguments passed +#' to \code{\link[colorsGen]{randomColor}} #' @param lty_edges,lwd_edges graphical parameters for the edges which are not #' border edges nor constraint edges #' @param lty_borders,lwd_borders graphical parameters for the border edges @@ -36,7 +38,6 @@ #' in the examples of \code{\link{delaunay}}. #' #' @export -#' @importFrom randomcoloR randomColor distinctColorPalette #' @importFrom graphics plot polygon par segments #' @importFrom gplots col2hex #' @@ -53,7 +54,7 @@ #' opar <- par(mar = c(0, 0, 0, 0)) #' plotDelaunay( #' d, type = "n", xlab = NA, ylab = NA, axes = FALSE, asp = 1, -#' fillcolor = "random", luminosity = "dark", lwd_borders = 3 +#' fillcolor = "random", lwd_borders = 3 #' ) #' par(opar) #' @@ -134,7 +135,9 @@ plotDelaunay <- function( del, col_edges = "black", col_borders = "red", col_constraints = "green", - fillcolor = "distinct", hue = "random", luminosity = "light", + fillcolor = "random", + distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), + randomArgs = list(hue = "random", luminosity = "dark"), lty_edges = par("lty"), lwd_edges = par("lwd"), lty_borders = par("lty"), lwd_borders = par("lwd"), lty_constraints = par("lty"), lwd_constraints = par("lwd"), ... @@ -194,9 +197,9 @@ plotDelaunay <- function( triangles <- t(del[["mesh"]][["it"]]) ntriangles <- nrow(triangles) if(fillcolor == "random"){ - colors <- randomColor(ntriangles, hue = hue, luminosity = luminosity) + colors <- rcolors(ntriangles, randomArgs) }else if(fillcolor == "distinct"){ - colors <- distinctColorPalette(ntriangles) + colors <- distinctColors(ntriangles, distinctArgs) }else{ colors <- rep(fillcolor, ntriangles) } diff --git a/README.Rmd b/README.Rmd index 9b74566..ed6a27f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -145,7 +145,7 @@ del <- delaunay(points, edges) opar <- par(mar = c(0, 0, 0, 0)) plotDelaunay( del, type = "n", asp = 1, lwd_borders = 3, col_borders = "black", - fillcolor = "random", luminosity = "dark", col_edges = "yellow", + fillcolor = "random", col_edges = "yellow", axes = FALSE, xlab = NA, ylab = NA ) par(opar) @@ -203,7 +203,7 @@ del <- delaunay(xy, edges = rbind(edges1, edges2)) opar <- par(mar = c(0, 0, 0, 0)) plotDelaunay( del, type = "n", col_borders = "black", lwd_borders = 2, - fillcolor = "random", luminosity = "dark", col_edges = "white", + fillcolor = "random", col_edges = "white", axes = FALSE, xlab = NA, ylab = NA, asp = 1 ) polygon(xy[inner, ], col = "#ffff99") diff --git a/man/plotDelaunay.Rd b/man/plotDelaunay.Rd index 60cea7b..b9aa27f 100644 --- a/man/plotDelaunay.Rd +++ b/man/plotDelaunay.Rd @@ -9,9 +9,9 @@ plotDelaunay( col_edges = "black", col_borders = "red", col_constraints = "green", - fillcolor = "distinct", - hue = "random", - luminosity = "light", + fillcolor = "random", + distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")), + randomArgs = list(hue = "random", luminosity = "dark"), lty_edges = par("lty"), lwd_edges = par("lwd"), lty_borders = par("lty"), @@ -38,14 +38,17 @@ of the constraint edges which are not border edges; \item{fillcolor}{controls the filling colors of the triangles, either \code{NULL} for no color, a single color, \code{"random"} to get multiple -colors with \code{\link[randomcoloR]{randomColor}}, \code{"distinct"} -get multiple colors with \code{\link[randomcoloR]{distinctColorPalette}}, +colors with \code{\link[colorsGen]{randomColor}}, \code{"distinct"} +get multiple colors with \code{\link[Polychrome]{createPalette}}, or a vector of colors, one color for each triangle; in this case the the colors will be assigned in the order they are provided but after the triangles have been circularly ordered (see the last example)} -\item{hue, luminosity}{if \code{color = "random"}, these arguments are passed -to \code{\link[randomcoloR]{randomColor}}} +\item{distinctArgs}{if \code{fillcolor = "distinct"}, a list of arguments +passed to \code{\link[Polychrome]{createPalette}}} + +\item{randomArgs}{if \code{fillcolor = "random"}, a list of arguments passed +to \code{\link[colorsGen]{randomColor}}} \item{lty_edges, lwd_edges}{graphical parameters for the edges which are not border edges nor constraint edges} @@ -79,7 +82,7 @@ d <- delaunay(pts) opar <- par(mar = c(0, 0, 0, 0)) plotDelaunay( d, type = "n", xlab = NA, ylab = NA, axes = FALSE, asp = 1, - fillcolor = "random", luminosity = "dark", lwd_borders = 3 + fillcolor = "random", lwd_borders = 3 ) par(opar) diff --git a/src/Makevars b/src/Makevars index af0c9c3..f18428c 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,14 +1,2 @@ - -## With R 3.1.0 or later, you can uncomment the following line to tell R to -## enable compilation with C++11 (where available) -## -## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider -## availability of the package we do not yet enforce this here. It is however -## recommended for client packages to set it. -## -## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP -## support within Armadillo prefers / requires it -CXX_STD = CXX14 - PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) diff --git a/src/Makevars.win b/src/Makevars.win index af0c9c3..f18428c 100644 --- a/src/Makevars.win +++ b/src/Makevars.win @@ -1,14 +1,2 @@ - -## With R 3.1.0 or later, you can uncomment the following line to tell R to -## enable compilation with C++11 (where available) -## -## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider -## availability of the package we do not yet enforce this here. It is however -## recommended for client packages to set it. -## -## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP -## support within Armadillo prefers / requires it -CXX_STD = CXX14 - PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)