swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rendering rotated characters in a raster?


From: Phil Knight
Subject: Re: Rendering rotated characters in a raster?
Date: Fri, 10 Oct 1997 20:06:46 +0100

In article <address@hidden>, Benedikt Stefansson wrote:
>
>I'll jump in here for fun and then maybe Nelson or someone who actually
>knows what he is talking about can correct me.
>
>I think you don't need to mess around with any Tk/Tcl hacking to do this.
>Start by creating bitmaps for the characters (one nice utility that can
>help you with this are the ASCII graphics tools such as pbmtoascii).
>
>Then implement a class which is a wrapper around XPixmap (which is the
>class that actually copies the .xpm files into the Tk buffer). In this new
>class do the black magic you just described, i.e. by giving a command such
>as "rotateLeft", the class will map a base bitmap that has been read from a
>.xpm file into a rotated bitmap (both the source and the destination are
>going to be arrays of char's). I must have slept through my linear algebra
>classes so I'm not going to venture into the subject of rotating a matrix.
>
>Next either generate a new instance of XPixmap and hand it the generated
>array or overwrite the pixmap array in an existing XPixmap instance. (Note
>that XPixmap in the Swarmlibs now only knows how to read the array from
>file so you'll have to implement a new method which accepts a new array via
>pointer. Might take some tweaking because of memory allocation problems).
>
>Finally hand a pointer to the XPixmap instance over to the objects that
>require it to draw themselves on raster, as in Heatbugs. Using XPixmap
>allows you to avoid all Tk hacking (hopefully).
>
>Sorry that I can't provide you with code. And of course some Tk hacker
>might now a command that actually does all of this with the original
>buffer. (Check out createEnd in XPixmap for hints)
>

Thanks for the tip. Though its not quite what I'm after I've got
something working along these lines. The X stuff worked on a wing and a
prayer (as I mentioned in my original post I know diddly-squat about X
programming), but fortunately there was nothing wrong that I couldn't
see how to fix :-)

What I'd really like to be able to do is to set up the pixmap straight
from a specified char without setting up separate xpm files. Also, I'm
not sure how to set the background and foreground colours on the
generated pixmap.

I've cobbled together a swarm app which includes two classes -
stateImage and statePixmap - which do the rotation stuff. The app is a
version of the Collins/Jefferson artificial ant/trail following
experiment and uses the Breeder libs (included) to do the genetic bit.
Its at http://www.pknight.demon.co.uk/swarm

I'd be really grateful if someone could take a quick look at these
classes and perhaps give me some advice on how to make the modifications
mentioned above.

Thanks in advance,
-- 
Phil Knight

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]