Bor*_*ino 3 rgb hex r color-space cielab
使用 R 很容易RGB
将HEX
值转换为值:
x <- c("165 239 210", "111 45 93")
sapply(strsplit(x, " "), function(x)
rgb(x[1], x[2], x[3], maxColorValue=255))
#[1] "#A5EFD2" "#6F2D5D"
Run Code Online (Sandbox Code Playgroud)
如何将 CIELab 值转换为 RGB 和 HEX?
x <- c("20 0 0", "50 0 0")
[...code...]
#[1] "#303030" "#777777"
Run Code Online (Sandbox Code Playgroud)
这是一种使用方法 library(colorspace)
library(colorspace)
z <- c("20 0 0", "50 0 0")
b <- do.call(rbind, lapply(strsplit(z, split = " "), as.numeric))
b <- LAB(b)
as(b, "RGB")
#output:
R G B
[1,] 0.02989077 0.02989025 0.02989294
[2,] 0.18418803 0.18418480 0.18420138
Run Code Online (Sandbox Code Playgroud)
它不能直接转换为HEX,但可以转换为:RGB、XYZ、HSV、HLS、LAB、polarLAB、LUV、polarLUV。
归档时间: |
|
查看次数: |
928 次 |
最近记录: |