Skip to content

Commit

Permalink
get rid of 'randomcoloR' package
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Oct 30, 2023
1 parent 90d62bc commit bfcf75e
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 31 deletions.
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: sphereTessellation
Title: Delaunay and Voronoï Tessellations on the Sphere
Version: 1.1.0
Version: 1.1.0.9000
Authors@R:
person("Stéphane", "Laurent", , "laurent_step@outlook.fr", role = c("aut", "cre"))
Description: Performs Delaunay and Voronoï tessellations on spheres and
Expand All @@ -10,8 +10,9 @@ License: GPL-3
URL: https://github.com/stla/sphereTessellation
BugReports: https://github.com/stla/sphereTessellation/issues
Imports:
colorsGen,
grDevices,
randomcoloR,
Polychrome,
Rcpp,
rgl
LinkingTo:
Expand All @@ -22,6 +23,7 @@ LinkingTo:
Suggests:
cooltools,
uniformly
Remotes: stla/RcppCGAL
SystemRequirements: C++ 17, gmp, mpfr
Encoding: UTF-8
RoxygenNote: 7.2.3
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export(VoronoiOnSphere)
export(icosphereMesh)
export(plotDelaunayOnSphere)
export(plotVoronoiOnSphere)
importFrom(Polychrome,createPalette)
importFrom(Rcpp,evalCpp)
importFrom(colorsGen,randomColor)
importFrom(grDevices,colorRamp)
importFrom(grDevices,hcl.colors)
importFrom(grDevices,rgb)
importFrom(randomcoloR,distinctColorPalette)
importFrom(randomcoloR,randomColor)
importFrom(rgl,arc3d)
importFrom(rgl,icosahedron3d)
importFrom(rgl,shade3d)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# sphereTessellation 1.1.0.9000

The package does no longer depend on the 'randomcoloR' package. Instead, it
now depends on the 'colorsGen' and 'Polychrome' packages.


# sphereTessellation 1.1.0

- Now the package does not depend on the s2 package.
Expand Down
16 changes: 16 additions & 0 deletions R/colors.R
Original file line number Diff line number Diff line change
@@ -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)
}
20 changes: 12 additions & 8 deletions R/delaunay.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ plotDelaunayEdges <- function(vertices, radius, center, color, lwd) {
#' @param del an output of \code{\link{DelaunayOnSphere}}
#' @param colors controls the filling colors of the triangles, either
#' \code{NA} for no color, or a single color, or \code{"random"} to get
#' multiple colors with \code{\link[randomcoloR]{randomColor}}, or
#' multiple colors with \code{\link[colorsGen]{randomColor}}, or
#' \code{"distinct"} to get multiple colors with
#' \code{\link[randomcoloR]{distinctColorPalette}}
#' \code{\link[Polychrome]{createPalette}}
#' @param distinctArgs if \code{colors = "distinct"}, a list of arguments
#' passed to \code{\link[Polychrome]{createPalette}}
#' @param randomArgs if \code{colors = "random"}, a list of arguments passed
#' to \code{\link[colorsGen]{randomColor}}
#' @param edges Boolean, whether to plot the edges
#' @param vertices Boolean, whether to plot the vertices
#' @param hue,luminosity if \code{colors = "random"}, these arguments are
#' passed to \code{\link[randomcoloR]{randomColor}}
#' @param ecolor a color for the edges
#' @param lwd line width for the edges, if they are plotted
#' @param vcolor a color for the vertices
Expand All @@ -116,7 +118,6 @@ plotDelaunayEdges <- function(vertices, radius, center, color, lwd) {
#'
#' @return No value is returned.
#' @export
#' @importFrom randomcoloR randomColor distinctColorPalette
#' @importFrom rgl spheres3d
#'
#' @examples
Expand All @@ -129,7 +130,10 @@ plotDelaunayEdges <- function(vertices, radius, center, color, lwd) {
#' open3d(windowRect = 50 + c(0, 0, 512, 512), zoom = 0.8)
#' plotDelaunayOnSphere(del)
plotDelaunayOnSphere <- function(
del, colors = "random", edges = FALSE, vertices = FALSE,
del, colors = "random",
distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")),
randomArgs = list(hue = "random", luminosity = "bright"),
edges = FALSE, vertices = FALSE,
hue = "random", luminosity = "bright", ecolor = "black", lwd = 3,
vcolor = "black", vradius = NA, ...
) {
Expand All @@ -143,9 +147,9 @@ plotDelaunayOnSphere <- function(
Faces <- del[["faces"]][solidFaces, ]
if(isString(colors)) {
if(colors == "random") {
colors <- randomColor(length(Meshes), hue = hue, luminosity = luminosity)
colors <- rcolors(length(Meshes), randomArgs)
} else if(colors == "distinct") {
colors <- distinctColorPalette(length(Meshes))
colors <- distinctColors(length(Meshes), distinctArgs)
} else{
colors <- rep(colors, length(Meshes))
}
Expand Down
19 changes: 12 additions & 7 deletions R/voronoi.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ plotVoronoiEdges <- function(cell, radius, center, color, lwd) {
#' @param vor an output of \code{\link{VoronoiOnSphere}}
#' @param colors controls the filling colors of the triangles, either
#' \code{NA} for no color, or a single color, or \code{"random"} to get
#' multiple colors with \code{\link[randomcoloR]{randomColor}}, or
#' multiple colors with \code{\link[colorsGen]{randomColor}}, or
#' \code{"distinct"} to get multiple colors with
#' \code{\link[randomcoloR]{distinctColorPalette}}
#' \code{\link[Polychrome]{createPalette}}, or \code{"gradient"}
#' @param distinctArgs if \code{colors = "distinct"}, a list of arguments
#' passed to \code{\link[Polychrome]{createPalette}}
#' @param randomArgs if \code{colors = "random"}, a list of arguments passed
#' to \code{\link[colorsGen]{randomColor}}
#' @param palette this argument is used only when \code{colors="gradient"}; it
#' can be either a character vector of colors, or the name of a palette
#' which will be passed to the \code{palette} argument of the function
Expand All @@ -143,7 +147,6 @@ plotVoronoiEdges <- function(cell, radius, center, color, lwd) {
#'
#' @importFrom rgl spheres3d
#' @importFrom grDevices hcl.colors
#' @importFrom randomcoloR randomColor distinctColorPalette
#'
#' @export
#'
Expand All @@ -170,9 +173,11 @@ plotVoronoiEdges <- function(cell, radius, center, color, lwd) {
#' next3d()
#' plotVoronoiOnSphere(vor, palette = "Viridis", bias = 1.1)}
plotVoronoiOnSphere <- function(
vor, colors = "gradient", palette = "Rocket", bias = 1,
vor, colors = "gradient",
distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")),
randomArgs = list(hue = "random", luminosity = "bright"),
palette = "Rocket", bias = 1,
edges = FALSE, sites = FALSE,
hue = "random", luminosity = "bright",
ecolor = "black", lwd = 3,
scolor = "black", sradius = NA, ...
) {
Expand All @@ -187,9 +192,9 @@ plotVoronoiOnSphere <- function(
palette <- hcl.colors(255L, palette = palette)
}
} else if(colors == "random") {
colors <- randomColor(length(vor), hue = hue, luminosity = luminosity)
colors <- rcolors(length(vor), randomArgs)
} else if(colors == "distinct") {
colors <- distinctColorPalette(length(vor))
colors <- distinctColors(length(vor), distinctArgs)
} else {
colors <- rep(colors, length(vor))
}
Expand Down
15 changes: 10 additions & 5 deletions man/plotDelaunayOnSphere.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions man/plotVoronoiOnSphere.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bfcf75e

Please sign in to comment.