[OpenJDK 2D-Dev] X11 uniform scaled wide lines and dashed lines; STROKE_CONTROL in Pisces

Jim Graham james.graham at oracle.com
Wed Oct 20 00:52:07 UTC 2010


Hi Denis,

On 10/18/2010 2:21 PM, Denis Lila wrote:
> I introduced a drawRoundCap method. This eliminated the side argument from
> the round join drawing, which made it easier to eliminate the trig function
> calls. I did this by using dot products to compute cosines (which was possible
> because now Stroker takes only untransformed paths, and all lineWidths are the
> same), and I used the double angle identities to compute any sines.
> I came up with my own ways of detecting acute/obtuse angles and finding the centres
> of angles ("my own" meaning I didn't look at any websites), and they consist of:
> 1. if (omx * mx + omy * my)>= 0 then the angle is acute (line 200).
> 2. I explain this in a comment in the file (line 208).

The new trig-less round join code looks great!  I don't see any errors, 
but a couple of nit comments:

One comment on the comment.  Isn't the upper bound on the ratio equal to 
sqrt(2)/2?  The radius (lineWidth2) is never greater than this chord 
length for any angle >90.

When would the isCW test trigger?  Does it track "rev"?  What happens at 
180 degrees (is that test reliable for the randomization that might 
happen when omxy are directly opposite mxy)?  The only reason I ask is 
because I think the sign of mmxy is probably controllable by 
understanding the input conditions, but this test should be safe (modulo 
if it really works at 180 degrees).  If it has failure modes at 180 
degrees then reworking the math to produce the right sign in the first 
place may be more robust for that case.  A test for this is to render 
"(0,0) -> (100,0) -> (0,0)" with round caps and then rotate it through 
360 degrees and see if the round caps invert at various angles.

Also, line 256 - does that track "rev"?

>> My head started spinning when evaluating the parallel curve methods so
>> I'll stop here for now...
>
> Sorry about that. Is there anything I can do to make it easier?

Actually I think I'm up to speed on all the math now.  I mainly have to 
double check the bookkeeping stuff a second time.  Can you let me know 
when you reach the end of my comment queue and I'll start the hopefully 
final proofread?

			...jim



More information about the 2d-dev mailing list