[cairo] Finding minimum distance to a stroke or fill

Ashwin Bharambe ashwinb at gmail.com
Wed Mar 1 15:23:27 PST 2006


Thanks for your mail, Carl. Yah, it's been a while since I was looking
at Cairo now...:)

> How about the following names instead:
>         cairo_distance_to_stroke
>         cairo_distance_to_fill
>

That sounds good enough... However, in my original usage, *I think* I
needed the nearest point as well. As you suggest, this functionality
could be added via a separate function.
(Very sadly, I have moved on from what I was trying to do at that time
-- namely, porting inkscape's renderer to cairo -- and so, I don't
remember  the exact use-case. Vaguely, it was related to implementing
some canvas-like functionality.)

> Internally to cairo I've used naming of "distance_squared" to make the
> distinction clear from any "distance" function. Should we actually
> provide all four functions:
>
>         cairo_distance_squared_to_stroke
>         cairo_distance_to_stroke
>         cairo_distance_squared_to_fill
>         cairo_distance_to_stroke
>

Yah, that sounds appropriate. Except there would be a large set of
functions here (with thin wrappers), which is fine also, I suppose.
You could just the distance_squared functions in the API, perhaps
(since the client can do the sqrt() if it wants to ... ) I think I am
not experienced enough regarding such API usage to suggest a choice
here.

Ashwin


More information about the cairo mailing list