[cairo] Finding minimum distance to a stroke or fill
Bill Spitzak
spitzak at d2.com
Mon Feb 14 12:02:52 PST 2005
It would be nice to return a negative distance if the point is inside
the path. This is called "level set" representation, and you can
reproduce suprisingly complex shapes from only a regular grid of such
values. This is used in 3-D for modelling organic shapes and also for
fluid simulations.
It looks like your code could be modified to do this easily except it
will return the distance to internal trapazoid divider lines. However I
believe this is actually an acceptable result and a legal level-set
representation of the shape.
You might also want to remove the sqrt() from the return value. The
caller can do this and some time is saved if they actually don't need
the root, for instance if they are just comparing to find the nearest one.
Ashwin Bharambe wrote:
> Hi all,
>
> Attached is a patch which adds two new functions to the cairo API. The
> functions provide functionality for finding the closest point to a
> stroke/fill from a given point (x, y). The function returns the
> distance as well as the co-ordinates of the closest point (px, py).
> Note that returning the distance is redundant and this need not be
> done. The actual signatures of the functions are:
More information about the cairo
mailing list