如何在Julia中打印具有指定RGB值的文本?

Ree*_*Oei 5 julia

例如,假设我想使用以下颜色打印文本:

R:0.5

G:0.8

B:0.1

我知道,print_with_color()但据我所知它必须使用a Symbol来打印,我不知道如何为任意颜色创建一个,或者如果这实际上是可能的.

cor*_*ion 4

可能:

julia> function print_rgb(r, g, b, t)
           print("\e[1m\e[38;2;$r;$g;$b;249m",t)
       end
print_rgb (generic function with 1 method)

julia> for i in 0:100
           print_rgb(rand(0:255), rand(0:255), rand(0:255), "hello!")
       end
Run Code Online (Sandbox Code Playgroud)

颜色漂亮的 Julia 终端