hypertidy / ximage

good image()
https://hypertidy.github.io/ximage/
Other
7 stars 1 forks source link

alpha() for nativeRaster #9

Open mdsumner opened 10 months ago

mdsumner commented 10 months ago

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

mdsumner commented 10 months ago

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" ...
--