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

Jim Graham james.graham at oracle.com
Wed Aug 11 21:50:00 UTC 2010

```Denis Lila wrote:
> Hi Jim.
>
>> I think the first version is a better choice for now since you said that
>> the performance difference isn't noticeable.  I think the lower level
>> flattening might look a little different if we ever decide to upgrade
>> the pipeline to deal with curves.  In particular, you are still
>> flattening above the dashing/stroking code and I think the flattening
>> should be done below that code (i.e. in Renderer).
>
>     Wouldn't we still need to flatten for dashing? Is there some way to
> quickly compute the arc length of a bezier curve from t=0 to t=some_number?
> As far as I can see the function for this computation is the integral of
> sqrt(polynomial_of_degree_4), and that would be pretty nasty.
> Or maybe we can get around this somehow?

There should be.  Google turns up a few hits for "compute arc length for
bezier curve" that should be enlightening.

BTW, have you looked at a widened dashed curved path with the closed
JDK?  I'm pretty sure it outputs dashed curves which proves the point.

I have also computed these lengths for other projects (the shape
morphing used in some JavaOne demos and Java FX) using the following
process:

- Compute the length of the control polynomial.
- Compute the length of the line between the endpoints.
- When they are within "epsilon" return the average as the arc length.
- Otherwise subdivide and try again.

I think you could also do something that looked at the relative angles
of all of the control segments and if they are close enough to each
other then you can compute the arc length using a simplified equation or
simply empirically match this to the "close enough" rule as above.

...jim

```