delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/22/21:45:38

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Background colour for text using Allegro
Date: Wed, 22 Apr 1998 19:20:38 +0100
Organization: None
Message-ID: <SuAjREA2TjP1EwEd@talula.demon.co.uk>
References: <6h50av$f3s AT news DOT network DOT com>
<Pine DOT ULT DOT 3 DOT 95 DOT 980422172717 DOT 6504A-100000 AT manes DOT vse DOT cz>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 30
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Michal Mertl writes:
>> To show at what speed a line should be typed, a coloured bar moves 
>> along the text line making a background for the text, changing the 
>> original white background to, for example, green. I would like to do 
>> this without rewriting the text,
>
> Do you mean to draw the text only once? If so you can't do that with 
> any Allegro function. 

Actually it could be done using a translucent drawing mode. Set up a
custom color_map table that will map every source/dest combination to an
unmodified copy of the source color, except when the destination value
is your text color, in which case the table should contain a copy of
this dest color. Call drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0), and
your rectfill() calls will skip over the text.

If you don't like to generate the mapping table in code, it can be
produced using the colormap utility, eg:

    colormap trans palette.pcx colormap.bin 255 255 255 ds=<col>

where palette.pcx contains the palette your program is using, and <col>
is the color of your text. This will produce the colormap.bin file,
which can be loaded by your program and referenced by the global
color_map pointer.


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Pigs use it for a tambourine" - Frank Zappa

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019