例如,假设我想使用以下颜色打印文本:
R:0.5
G:0.8
B:0.1
我知道,print_with_color()但据我所知它必须使用a Symbol来打印,我不知道如何为任意颜色创建一个,或者如果这实际上是可能的.
可能:
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)
