Re: std/graphcst.e colors in OSX - cont.
- Posted by jimcbrown (admin) Nov 12, 2009
- 1213 views
dukester said...
This whole thread started when I posted this code:
07:01 pm >> cat demo52.ex -- demo program 52 -- from Beginners Guide to Euphoria include graphics.e integer foreground_color sequence list_of_colors, already_used clear_screen() list_of_colors = {"BLUE","GREEN","CYAN","RED","MAGENTA","BROWN", "WHITE","GRAY","BRIGHT_BLUE","BRIGHT_GREEN", "BRIGHT_CYAN","BRIGHT_RED","BRIGHT_MAGENTA", "YELLOW","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
to this forum, asking why the color of the text did not match what the text said that the color should be. The problem colors were blue and red, yellow and cyan. I asked if there was something wrong with the code itself - being new to Euphoria and all. The code still gives haywire results. I didn't know whether the code was at fault; graphics.e; or my OSX. Must be the code...
Thanks for all you guy's help.
Ah, yes, it is the code, the code is assuming Windows/DOS colors. Not OS/X colors. ABGTE was written before Euphoria ran on Mac OS X. (I think it was written before Mac OS X existed.)
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