[as-devel] Re: Rotating text, and other funky text effects.
Ethan (allanon@crystaltokyo.com)
Thu, 22 Apr 1999 13:38:14 -0700 (PDT)
On Thu, 22 Apr 1999 Sasha_Vasko@osca.state.mo.us wrote:
> Looking at all this rotating text posts on AS ML I had a most wonderfull idea,
> as to how to implement this and some other stuff without too much resource
> utilization.
>
> What we can do is to employ the same approach used in GIMP when text is
> created, by maksing one layer with another:
>
> a) Preparation :
> 1. We create pixmap of 1bpp color depth of the size of the text in the title
> bar,
> 2. We DrawText of the titlebar into this pixmap with white color.
> 3. We rotate this pixmap -90 degrees, if vertical text is desired.
> We can do this only when text to be displayed changes, and then just store
> this prepared Mask in some safe place.
Step 3 isn't much fun with a 1bpp pixmap, but since we know the depth
and it doesn't matter if it is XYPixmap or ZPixmap, it probably would be
reasonably easy. Also, step 3 involves:
3a. Convert Pixmap to XImage.
3b. Create new XImage of appropriate size.
3c. Copy source to destination, applying rotation.
3d. Create new Pixmap of appropriate size.
3e. Copy rotated XImage to new Pixmap.
Steps 3a and 3e are the ones that bother me, not 3c.
<soapbox>
I mention it because in these days of Linux and X being used like
M$-Windows (ie, clients on the same box as server), people tend to forget
that X is a networked protocol. Pixmap to XImage conversions (and vice
versa) are _not_ fast, particularly when X is being run remotely.
AfterStep, unlike some current window managers, still runs well over a
net connection - I'd like to see it stay that way. Translucency is a
notable exception, and I still have twinges of regret for implementing
it...
</soapbox>
> b) Usage :
> 1.) We cut a piece of prepared pixmap of the size of titlebar, if it's smaller
> then pixmap.
> 2) We create another pixmap of the same size, and fill it with text color
> 3) We display text on the titlebar by masking second pixmap with our prepared
> mask pixmap.
Even easier, set the GC clipping mask to our 1bpp text pixmap, set the
clip origin appropriately, and use XFillRectangle to draw the text. No
need for an extra pixmap at this stage.
> 3D look can be achieved , by simply repeating this operation,
> shifting Mask a few pixels, while dimming second pixmap to get Relief colors.
A good point.
> -90 degrees rotation is merely linear memory copy operation and should not
> be a CPU hog if we employ similar techiques as in shading functions ( direct
> access to XImage storage ).
See above for discussion. :)
> All this operations are not very resource consuming, and I bielive that it could
> be even faster then regular DrawText, even thou it will eat up some memory.
> So we could possibly utilize this approach for all other displaying operations.
Could be, although I'd rather not keep hundreds (or even tens) of pixmaps
lying around - they're a logistical nightmare to keep up to date.
> Another nice feature becomes possible : pixmapped, gradiented or transparent
> text, as far as it does not make much difference with what we fill our pixmap
> to be masked.
> So ForeGradient and ForePixmap becomes possible options of MyStyle definition :)
Yup, that would be very nice. I've been hoping this would become possible
ever since I designed the MyStyles; looks like it might become a reality! :)
To summarize, I still object to rotating text, on the basis that it
requires transferring the pixmap from X server to local client and back.
I do think that using a pixmap to represent the text would be a good way
of doing ForePixmap and ForeGradient.
----
Ethan Fischer
allanon@crystaltokyo.com
http://members.xoom.com/allanon1