Skip to content

Commit

Permalink
fix: fill color values with alpha values in 'gradient' and 'plasma'
Browse files Browse the repository at this point in the history
* `gridpattern_gradient()` when `use_R4.1_gradients=FALSE` and
  `gridpattern_plasma()` now allow alpha values to be specified
  within the `fill` (and `fill2`) colour values.
  • Loading branch information
trevorld committed Nov 29, 2021
1 parent 87be956 commit bf8d342
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ Bug fixes and minor improvements
(a "two-pointed star" polygon is a rhombus).
* Fixes `grid.pattern_gradient()` when `use_R4.1_gradients=TRUE` to better
match behavior when `use_R4.1_gradients=FALSE`.
* Now allows alpha values to be specified
within the `fill` (and `fill2`) colour strings for
`gridpattern_plasma()` and `gridpattern_gradient()` (when `use_R4.1_gradients=FALSE`).

gridpattern v0.2.1
==================
Expand Down
7 changes: 4 additions & 3 deletions R/utils-magick-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
#'
#' @param col may be a built in colour, like 'tomato' or a hex colour
#'
#' @return always returns a hex colour, except if col is NA when it retuns a special
#' @return always returns a hex colour, except if col is NA when it returns a special
#' magick colour 'none', which means transparent
#'
#' @noRd
convert_r_colour_to_magick_colour <- function(col) {
if (is.null(col) || is.na(col) || length(col) == 0) {
if (is.null(col) || is.na(col) || length(col) == 0 || col == "transparent") {
return('none')
}
rgb(t(col2rgb(col)), maxColorValue = 255)
col_rgb <- col2rgb(col, alpha = TRUE)
rgb(col_rgb[1], col_rgb[2], col_rgb[3], col_rgb[4], maxColorValue = 255)
}

#' Convert a magick image to an RGBA array.
Expand Down

0 comments on commit bf8d342

Please sign in to comment.