[racket] More than one color with draw-text?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Dec 12 18:02:03 EST 2011

Creating images for each character you plan to display will probably
have two disadvantages: it will use more memory, and it will void the
work that the OS does to make letters fit together (ligatures and
sometimes kerning).

(Probably using picts is the right way to go.)


On Mon, Dec 12, 2011 at 4:54 PM, Will Robinson
<quantum.penguin at gmail.com> wrote:
> Thanks everyone for the suggestions.
> Stephen, to answer your question, I want to be able to change the text
> independently.  The letter d, for example, I might want to show sometimes in
> white, red, or green.  I guess I could make a pic for each though.
> On Mon, Dec 12, 2011 at 4:31 PM, Stephen Bloch <bloch at adelphi.edu> wrote:
>> On Dec 12, 2011, at 10:53 AM, Will Robinson wrote:
>> > Hello,
>> >
>> > I'm trying to do a simple Roguelike game as an exercise in learning the
>> > language, particularly racket/gui.  I'm using draw-text to place characters
>> > on the screen.  Ideally, I'd just call this once and put up huge string full
>> > of newlines to represent a block of text.  My problem is that I want to have
>> > control of the color of each character in this block of text.  It seems to
>> > me that the color controls for draw-text are applied to the entire block at
>> > once.  Should I just call draw-text for each character in the block,
>> > individually assigning color?  That seems to be very slow computationally,
>> > not to mention more work on the poor coder.
>> Are characters and their colors orthogonal?  That is, can any character
>> appear in any color, or does a particular character always appear in the
>> same color?  If the latter, I would just create a bunch of images up front
>> and place them at the desired (x,y) coordinates directly, rather than
>> re-rendering the text every time.  That'll actually be faster.
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Posted on the users mailing list.