How to print text with specified RGB value in Julia?

For example, let's say I want to print text using the following color:

R: 0.5

G: 0.8

B: 0.1

I know about print_with_color()

, but as far as I know, it should be used Symbol

for printing and I don't know how to create it for any arbitrary color, or if it is actually possible.

+3


source to share


1 answer


Maybe:

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

      



Julia terminal with pretty colors

+2


source







All Articles