hypertidy/ximage

alpha() for nativeRaster

mdsumner opened this issue · 1 comments

create a scales::alpha() for arrays, hex, rgb, nativeRaster that doesn't drop dimension

  • doesn't work on numbers
  • drops dimension
  • no handling for nativeRaster
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
 str(img)
# num [1:76, 1:100, 1:4] 0 0 0 0 0 0 0 0 0 0 ...
 scales::alpha(img, .2)
#Error: colours encodes as numbers must be positive

 str(scales::alpha(matrix(rgb(img[,,1], img[,,2], img[,,3], img[,,4]), nrow(img)), .2)
#chr [1:7600] "#00000033" "#00000033" "#00000033" "#00000033" "#00000033" "#00000033" "#00000033" ...
--