clip masks/simulating transparency

Amy C mathematical.coffee at gmail.com
Mon May 30 19:41:39 PDT 2011


Hi all,

Being recently introduced to xpenguins, I thought it would be hilarious to
get the penguins to run around in a window of my choice instead of the
desktop (small things for small minds...;)).

To this end I've started fiddling around with the xpenguins source and
learning Xlib along the way, and now there's just one thing left to do to
achieve heart-warming goodness.

The problem is that the penguins obscure the window on which they are drawn.
This can be demonstrated by getting xpenguins, using 'xwininfo' on a
terminal (say) to get the window ID, and then running

xpenguins -id <window ID>.

It would be best if the window were maximised and there be no other windows
on that desktop (I've put in some changes to get around this in my fiddling
but that's besides the point).

You see that the penguins leave little trails of window background colour
behind them. Every 100 cycles xpenguins sends an Expose event to the window
to remove these.
By sending an expose event every time a penguin is drawn I can eliminate the
trails entirely, _but_ the non-penguin part of the penguin rectangle itself
is still drawn in window colour (for the terminal, that grey colour windows
are by default).

>From examining the xpenguins source (ToonDraw in toon_draw.c), to draw the
penguins:
- the penguin clip mask is applied to the GC (these are penguin-shaped clip
masks, I've checked)
- the penguin pixmap is XCopyArea'd over to the window on which the penguins
are being drawn, using the GC with the clip mask.
- said clip mask is removed.

According to this, the non-penguin pixels should not be drawn on at all,
meaning that I shouldn't be getting bits of grey background on the penguins.

Does anyone know why this is still happening?

Other things I've tried are (assuming we're drawing penguins on a terminal):
- dropping a clear window (no background pixmap or background pixel) on top
of the terminal and drawing on that using the clip mask -- this removes the
grey background bits -but- it leaves a trail of penguin behind.
- XCopyArea-ing the relevant bits of the terminal onto my clear window to
cover up the penguin trail -- doesn't work (I assume because the terminal is
essentially covered up by my clear window/penguin trail?)
- First XCopyArea-ing the relevant bits of terminal onto my penguin pixmap,
THEN using the mask to copy just the penguin on top of that, and then
XCopyArea-ing that pixmap (ie entire rectangle, not using the mask) onto my
clear window.
This gives a weird flickering background that is often blue.

If anyone can give me some pointers I'd be grateful. I'm at the
tearing-hair-out stage.

[If anyone wants to give this a go I can send a working copy of what I've
done so far. ToonDraw() in toon_draw.c is the relevant function].

cheers (sorry for overly-long post)
Amy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20110531/722a6cb2/attachment.html>


More information about the xorg mailing list