Re: XShrinkRegion() distorts shape
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 9 Dec 2010 15:11:26 GMT
boltar2003@xxxxxxxxxxxx wrote:
I'm writing an app where I intended to use region that shrinks and expands
to do some graphics special effects, but I've noticed that any non
rectangular regions (in my case a triangle) seem to have their shape
distorted if shrunk then inflated again. The more they're shrunk the
greater the distortion. I realise I could just recreate a new region on
each iteration but this is horribly inefficient. Is there a better
solution?
My code is as follows:
xp[0].x = WIDTH / 2;
xp[0].y = 0;
xp[1].x = WIDTH;
xp[1].y = HEIGHT;
xp[2].x = 0;
xp[2].y = HEIGHT;
region = XPolygonRegion(xp,3,WindingRule);
:
while(1)
{
:
:
XShrinkRegion(region,sx,sy);
XSetRegion(display,gc,region);
XFlush(display);
:
:
}
Tthe explanations of what XShrinkRegion() I have found aren't
too clear on what is supposed to happen when you apply it to a
non-rectangular region. What's clear from the XLib Programming
Manual specifies that a Region is implemented as a group of non-
overlapping rectangles, so it doesn't keep any information about
the exact shape it was created from. Thus I fear that you expect
too much from a lowly XLib function if you expect it to keep the
exact shape under multiple shrinking and expansion operations.
Even if the function should do its best at trying to conserve
the shape as far as it's aware of it, you're going to get an in-
creasing amount of errors since all it can use is the knowledge
where pixels are set and where not (similar to what happens when
you for example reduce the resolution of a png file of a triangle
and then try to increase it again - the result won't look too
pretty). And that still assumes that XShrinkRegion() is even
trying to do the best possible job at keeping the shape - I am
not sure if you can even expect that...
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- Follow-Ups:
- Re: XShrinkRegion() distorts shape
- From: boltar2003
- Re: XShrinkRegion() distorts shape
- References:
- XShrinkRegion() distorts shape
- From: boltar2003
- XShrinkRegion() distorts shape
- Prev by Date: XShrinkRegion() distorts shape
- Next by Date: some questions about times function
- Previous by thread: XShrinkRegion() distorts shape
- Next by thread: Re: XShrinkRegion() distorts shape
- Index(es):
Relevant Pages
|