Skip to content

Commit

Permalink
v1.4.0 - get rid of 'randomcoloR'
Browse files Browse the repository at this point in the history
  • Loading branch information
stla committed Oct 30, 2023
1 parent 165b2f3 commit 4f2b9e2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 19 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: gyro
Title: Hyperbolic Geometry
Version: 1.3.0
Version: 1.4.0
Author: Stéphane Laurent
Maintainer: Stéphane Laurent <laurent_step@outlook.fr>
Description: Hyperbolic geometry in the Minkowski model and the Poincaré
Expand All @@ -16,18 +16,19 @@ URL: https://github.com/stla/gyro
BugReports: https://github.com/stla/gyro/issues
Imports:
clipr,
colorsGen,
cxhull (>= 0.3.0),
graphics,
grDevices,
Morpho,
plotrix,
Polychrome,
purrr,
Rcpp,
rgl,
rstudioapi,
Rvcg,
RCDT,
randomcoloR
RCDT
Suggests:
arrangements,
knitr,
Expand Down
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ export(plotGyrohull3d)
export(plotHdelaunay)
export(tiling)
importFrom(Morpho,mergeMeshes)
importFrom(Polychrome,createPalette)
importFrom(RCDT,delaunay)
importFrom(Rcpp,evalCpp)
importFrom(Rvcg,vcgClean)
importFrom(Rvcg,vcgGetEdge)
importFrom(clipr,clipr_available)
importFrom(clipr,write_clip)
importFrom(colorsGen,randomColor)
importFrom(cxhull,TrianglesXYZ)
importFrom(cxhull,VerticesXYZ)
importFrom(cxhull,cxhull)
Expand All @@ -38,8 +40,6 @@ importFrom(graphics,polypath)
importFrom(plotrix,draw.circle)
importFrom(purrr,flatten)
importFrom(purrr,imap)
importFrom(randomcoloR,distinctColorPalette)
importFrom(randomcoloR,randomColor)
importFrom(rgl,cylinder3d)
importFrom(rgl,lines3d)
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 @@
# gyro 1.4.0 (2023-10-30)

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


# gyro 1.3.0 (2023-08-07)

- New function `gyroray`.
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)
}
19 changes: 11 additions & 8 deletions R/hdelaunay.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,22 @@ hdelaunay <- function(
#' Ungar model
#' @param color this argument controls the colors of the triangles; it can be
#' \code{NA} for no color, \code{"random"} for random colors generated
#' with \code{\link[randomcoloR]{randomColor}}, \code{"distinct"} for
#' with \code{\link[colsGen]{randomColor}}, \code{"distinct"} for
#' distinct colors generated with
#' \code{\link[randomcoloR]{distinctColorPalette}}, a single color,
#' \code{\link[Polychrome]{createPalette}}, a single color,
#' a vector of colors (color \code{i} attributed to the \code{i}-th
#' triangle), or a vectorized function mapping each point in the unit
#' interval to a color
#' @param hue,luminosity passed to \code{\link[randomcoloR]{randomColor}}
#' if \code{color="random"}
#' @param distinctArgs if \code{color = "distinct"}, a list of arguments
#' passed to \code{\link[Polychrome]{createPalette}}
#' @param randomArgs if \code{color = "random"}, a list of arguments passed
#' to \code{\link[colorsGen]{randomColor}}
#'
#' @return No returned value, just generates a plot.
#' @export
#'
#' @importFrom plotrix draw.circle
#' @importFrom graphics par polypath lines points
#' @importFrom randomcoloR randomColor distinctColorPalette
#'
#' @examples
#' library(gyro)
Expand Down Expand Up @@ -180,7 +181,9 @@ hdelaunay <- function(
#' )
plotHdelaunay <- function(
hdel, vertices = TRUE, edges = TRUE, circle = TRUE,
color = "distinct", hue = "random", luminosity = "random"
color = "distinct",
distinctArgs = list(seedcolors = c("#ff0000", "#00ff00", "#0000ff")),
randomArgs = list(hue = "random", luminosity = "bright")
){
if(!inherits(hdel, "hdelaunay")){
stop("The `hdel` argument must be an output of the `hdelaunay` function.")
Expand Down Expand Up @@ -215,9 +218,9 @@ plotHdelaunay <- function(
colors <- color
}else{
if(color == "random"){
colors <- randomColor(ntriangles, hue = hue, luminosity = luminosity)
colors <- rcolors(ntriangles, randomArgs)
}else if(color == "distinct"){
colors <- distinctColorPalette(ntriangles)
colors <- distinctColors(ntriangles, distinctArgs)
}else{
colors <- rep(color, ntriangles)
}
Expand Down
15 changes: 9 additions & 6 deletions man/plotHdelaunay.Rd

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

0 comments on commit 4f2b9e2

Please sign in to comment.