Re: std/graphcst.e colors in OSX - cont.

new topic     » goto parent     » topic index » view thread      » older message » newer message
jimcbrown said...

[snip]

Try this code below:

include graphics.e 
integer foreground_color 
sequence list_of_colors, already_used 
 
clear_screen() 
 
list_of_colors = {"RED","GREEN","BROWN","BLUE","MAGENTA","CYAN", 
                   "WHITE","GRAY","BRIGHT_RED","BRIGHT_GREEN", 
                   "YELLOW","BRIGHT_BLUE","BRIGHT_MAGENTA", 
                   "BRIGHT_CYAN","BRIGHT_WHITE"} 
 
already_used = {} 
 
for ix = 1 to 10 do 
     foreground_color = rand(15) 
     while find(foreground_color,already_used) do 
          foreground_color = rand(15) 
     end while 
     already_used = already_used & foreground_color 
     text_color(foreground_color) 
     printf(1, "Text in %s\n",{list_of_colors[foreground_color]}) 
end for 

Well it works! However, I don't understand why changing the order of the color names would matter? After all, we're randomly choosing an index number to access a color in the sequence. But it does... good eye! Thanks.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu