Rev 80858 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
cols <- t(col2rgb(palette()))## One full space1-XYZ-space2 conversionconvertColor(cols, 'sRGB', 'Lab', scale.in=255)## to XYZ, then to every defined spaceXYZ <- convertColor(cols, 'sRGB', 'XYZ', scale.in=255)fromXYZ <- vapply(names(colorspaces), convertColor, FUN.VALUE=XYZ,from='XYZ', color=XYZ, clip=NA)round(fromXYZ, 4)## Back to XYZ, delta to original XYZ should be close to zerotol <- 1e-5toXYZ <- vapply(dimnames(fromXYZ)[[3]],function(x) all(abs(convertColor(fromXYZ[,,x], from=x, to='XYZ') - XYZ)<tol),logical(1))toXYZstopifnot(all(toXYZ | is.na(toXYZ)))## Test Apple and CIE RGB on smaller gamuts since they clipXYZ2 <- XYZ * .7 + .15fromXYZ2 <- vapply(c('Apple RGB', 'CIE RGB'), convertColor, FUN.VALUE=XYZ2,from='XYZ', color=XYZ2, clip=NA)round(fromXYZ2, 4)toXYZ2 <- vapply(dimnames(fromXYZ2)[[3]],function(x)all(abs(convertColor(fromXYZ2[,,x], from=x, to='XYZ') - XYZ2)<tol),logical(1))stopifnot(all(toXYZ2))# Seg.fault in R 3.5.3 -- 4.1.1 (but not 3.4.4) -- PR#18183stopifnot(identical(character(0),gray(numeric(), alpha=1/2)))