Hi,
I've been doing some fun wor,k creating cusomt UI delegates for Swing
lately. And I've come across an issue with LineGradientPaint, where I
want to create a gradient from some color (say white) to the
background color of my component, to create a typical gloss effect.
However, I find that no matter what I do, the gradient will never end
at the background color (it's always slightly off, enough to make a
visual artifact). I'm wondering if there is a reason for this? I
suspect there might be some hardware or native code acceleration
tricks going on here, that approximate colors? Is there a way or hint
to make it more accurate (I tried setting the rendering hint
COLOR_RENDERING to QUALITY with no success)?
My code looks something like this:
int x, y, w, h; // Bounds of my component
Graphics2D g;
Color background = getBackground();
g.setPaint(new LinearGradientPaint(x, y, x, y + h - 1, new float[] {.
2f, .5f}, new Color[] {Color.WHITE, background}));
g.fillRect(x, y, w, h);
My background color is 0xE8E8E8 (RGB), but the gradient fades from
0xFFFFFF to 0xEEEEEE halfway through, and then continues with that
color.
PS: I'm using Java 6 for Mac OS X, which may have their own
optimizations. I'll ask in a Mac forum as well, but want to know if
this is a general problem first.
Best regards,
--
Harald K
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".