Re: Rounded Polyline, and other questions?




On Thu, Jul 01, 2004 at 09:44:57AM +0200, larsrc raeder dk wrote:

Okay, attached is the patch for the per corner minimum radius.


Thanks, it has been applied.

As for making rounded corners for the polygon, unfortunately it's not just
a question of adding the corner_radius field and reusing the polyline
code.  A polygon also has to be filled, and a little more thought will
have to go into how to fill rounded corners correctly.  Probably cut the
polygon tips and add arcs. 

Yeah I had figured this out as well.  In the case of concave(?) polygons
(ie, those that don't turn in on themselves) its pretty simple, do
the calculations for the arcs which modifies the end points of each
section, this gives you a new polygon with twice as many segments,
then fill the arcs and the polygon (ie, what you mention, cut the
tips and add arcs).  However, with a polygon which
turns in on itself, I believe the filling for the arc would be
wrong (the arc fills out a pie slice where in this case you want
the outer area filled)

In other words think of a polygon like this
+---------+
|         |
|    +    |
|   / \   |
|  /   \  |
| /     \ |
|/       \|
+         +

If you calculate the intersection points for the arcs of a particular
diameter you end up with these points ('*'s, where each arch would connect
from a '*' point to a '*' point)

+-*-----*-+
|         |
*    +    *
|   /a\   |
|  *   *  |
* *     * *
|/       \|
+         +

Hopefully you see that the problem is with area 'a'.  The arc in this
case needs to be filled on the other side then the standard case.

One solution which I've been thinking about (and which the beziergons
seem to use) is to leave the area alone if it is in this situation
and creating a new polygonal section like this

      +
     / \
    /   \
   /_---_\
  /'     `\
 *         *
Which you could use polygon fill in.

Only thing I'm not sure of is how to determine that a section like
'a' exists.  If I can figure out that those sections exist I can
hopefully get a polygon like

  *-----*
 /       \
*    +    *
|   /a\   |
|  *   *  |
*-*     *-*

where all the corners which were clipped are filled arcs and area 'a'
is a generated and filled polygonal arc approximation.

Does that make sense?  Am I missing something?  Wait does arc filling
look like

    _---_
   '     `
  *-------*

or 
    _---_
   '     `
  *       *   ?
   \     /
    \   /
     \ /
      *

If it's the latter then I could run into problems with really concave
shapes, the tip of the pie slice could be past the wall of the opposite
side of the polygon.  Maybe all the corners need to be replaced with
polygonal representations?

In fact, that may be a better way to do the rounded boxes as well.
 
Not certain, I believe right now it fills out 3 rectangles and 4 arcs,
with cuttin of corners you might get that to 1 polygon and 4 arcs
however I would have to assume that rectangle filling is faster?

-Anthony

-- 
------------------------------------------------------------------------
Anthony Molinaro                                 <anthonym overture com>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]