Skip to content

Commit

Permalink
minor bug, when mixed color is not in spectral library
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Oct 12, 2023
1 parent 2b2ab7f commit 646e057
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# aqp 2.0.2 (2023-09-14)
# aqp 2.0.2 (2023-10-11)
* new function `col2Munsell()` generalizes and replaces `rgb2munsell()` (thanks Shawn Salley for the suggestion)
* new function `warpHorizons()` for warping horizon thickness (inflate/deflate) (thanks Shawn Salley for idea / inspiration)
* fixed minor bug in `plotColorMixture()` when final mixed color does not exist in spectral library

# aqp 2.0.1 (2023-09-03)
* CRAN release (CRAN check bugfix)
Expand Down
19 changes: 19 additions & 0 deletions R/plotColorMixture.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,25 @@ plotColorMixture <- function(x, w = rep(1, times = length(x)) / length(x), mixin
# last color is the mixture,
# replace reference spectra / munsell chip with actual mixture
if(i == length(colors)) {

# avoid trying to append to a 0-length DF
# if the last color has no reference spectra
if(nrow(z) < 1) {
# pad with NA
z <- z[1:length(mx$spec), ]

# fill columns with pieces of the closest Munsell
.pm <- parseMunsell(mx$mixed$munsell, convertColors = FALSE)
z$hue <- .pm$hue
z$value <- .pm$value
z$chroma <- .pm$chroma

## NOTE: hard-coded spectra wavelengths!!
# fill wavelength column
z$wavelength <- seq(from = 380, to = 730, by = 10)
}

# save mixed spectra and closest Munsell color
z$reflectance <- mx$spec
z$munsell <- mx$mixed$munsell
}
Expand Down

0 comments on commit 646e057

Please sign in to comment.