Task

Display a word in various colours on the terminal.

The system palette, or colours such as Red, Green, Blue, Magenta, Cyan, and Yellow can be used.



Optionally demonstrate:

 How the system should determine if the terminal supports colour
 Setting of the background colour
 How to cause blinking or flashing (if supported by the terminal)


import "timer" for Timer
 
var colors = ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"]
 
// display words using 'bright' colors
for (i in 1..7) System.print("\e[%(30+i);1m%(colors[i])") // red to white
Timer.sleep(3000)         // wait for 3 seconds
System.write("\e[47m")    // set background color to white
System.write("\e[2J")     // clear screen to background color
System.write("\e[H")      // home the cursor
 
// display words again using 'blinking' colors
System.write("\e[5m")     // blink on
for (i in 0..6) System.print("\e[%(30+i);1m%(colors[i])") // black to cyan
Timer.sleep(3000)         // wait for 3 more seconds
System.write("\e[0m")     // reset all attributes
System.write("\e[2J")     // clear screen to background color
System.write("\e[H")      // home the cursor