Mail Archives: djgpp/1998/04/24/20:01:57
Hello Mike,
Sorry if this is off topic.
xmerm05 AT manes DOT vse DOT cz on 04-23-98 Spoke to All about Re: Background
colour for
x>From: Michal Mertl <xmerm05 AT manes DOT vse DOT cz>
x>Subject: Re: Background colour for text using Allegro
x>Organization: Prague University of Economics
x>On 16 Apr 1998, Mike Collins wrote:
x>> I am trying to use Allegro to write a simple typing tutor.
x>> Initially, the screen is white with black text on it that has to be
x>> read and typed. To show at what speed a line should be typed, a
x>> coloured bar moves along the text line making a background for the
x>> text, changing the original white background to, for example,
x>> green. I would like to do this without rewriting the text, but
x>> everything I have tried simply hides the text under my colour bar.
x>Do you mean to draw the text only once? If so you can't do that with
x>any Allegro function.
Not quite true..
If he sets up his palette correctly say:-
0=black , 1=white, 254=yellow, 255=red.
use a function like:-
// Reverse the color field of given block
void my_xor_block(BITMAP *bmp, int x, int y, int w, int h)
{
int x1=x+w;
int y1=y+h;
xor_mode(TRUE);
show_mouse(NULL);
rectfill(bmp, x, y, x1, y1,255);
show_mouse(screen);
xor_mode(FALSE);
}
To change the text color you pass the paramaters of the screen area and
presto the text colors are altered to the values of the colors at the
opposing palette position.
In the above case the black would turn to red and the white would turn
yellow.
if we XOR (as in the above function) with 255 the folowing results.
color 0 = 255
1 = 254
2 = 253
. . ...
127 = 128
128 = 127
... . ...
254 = 1
255 = 0
To restore the screen simply call the routine again..
Of course if you aren't concerned what color is displayed you needn't
alter the palette at all and simply find an XOR value that returns
something close..
Hope that helps...
(OH! Well, Lifes like that Sumtimes) With regards Ron T Lewis
EMail........ ron DOT t DOT lewis AT bbs DOT st DOT net DOT au
___
X CMPQwk #1.42X REGISTERED COPY
- Raw text -