For those that don't want to
read my motivation for this email, here's essentially what I'm looking for: Is
there some sort of Composite that does a comparison of the SRC and DEST pixels
and retains the darker of the two? If not, how would I go about
implementing one? Or is there a better
way?
Here's why I'm
asking: I'm trying to implement feathered drop shadows for a number of
rectangles and I'm having some difficulty combining the resulting shadows into a
smooth backdrop. For example, let's say I have a rectangle A. The
shadow that A casts is essentially a rounded rectangle, but instead of
using a RoundRectangle2D, I composed the shadow out of a rectangle of
the same size as A in the middle, 4 smaller rectangles on the sides, top
and bottom, and then 4 arcs for the 4 corners:
Arc Rect Arc
Rect Rect
Rect
Arc
Rect Arc
The rectangle in the
middle is then painted black with an alpha value, and then the 4 sides are
painted the same black with a gradient paint that is reduced heading outwards
from the middle rectangle. The 4 arcs on the corners are painted black
with a RadialGradient paint the lightens as you head outwards from the
corner. So what I get for the shadow is a nice rounded rectangle that is
larger than the original with a gradient paint on the edges that gradually
lightens. This looks great.
The problem arises
when I have the rectangle A near or next to another Rectangle, say B. If I
use SRC_OVER as an alpha composite for the shadow buffer, then the shadows
(because they are larger than the rectangles that cast them) combine as if they
are from two light sources and you get a dark section where they come
together. If I use SRC, then whichever shadow get's drawn second destroys
the feathering around the first shadow because the gradient paint on the edges
of the second shadow overwrites the edges on the first
shadow.
So what I'm looking
for is a Composite that looks at two pixels and retains the darker of the two,
so that when the shadows overlap, it will look like their pixles have
been merged together instead of combined.
Thanks for any
help.
-Brian
