Thanks, Tal and Frederik,
I've built a pen for it. I love pens :)
The closestPointFactory doesn't do exactly what I wanted, which is the closest of the existing points (excluding off-curve points).
(The closestPointFactory returns the coordinate of the shortest distance from the reference point to the curve of the closest contour.)
Cheers,
Jens
> -----Original Message-----
> Behalf Of Frederik Berlaen
>
> or in case you are using RoboFont you can use:
>
> """
> g = CurrentGlyph()
> closestPointFactory = g.naked().getRepresentation("doodle.closestPoint")
> contourIndex, pointOnTheCurve =
> closestPointFactory.getClosestContourIndex((100, 100))
> """
>
> but I guess Ive spoiled your nice evening finding it out :)
>
> good luck!
>
> gr Frederik
>
www.typemytype.com
>
>
>
> On 03 Sep 2013, at 19:33, Tal Leming wrote:
>
> > I think you'll have to bake your own.
> >
> > A custom point pen might be the easiest way to do it. You could store
> something like (x, y, contour index, point index) for all points passed through
> addPoint and then iterate over that when you test the coordinate. Or you could
> start the pen with the coordinate and as a point comes in through addPoint you
> could test the distance and store the contour index and point index if the
> distance is closer to the coordinate than the point that was formerly closest. If
> there is a direct hit, you can stop. Or... Lots of fun ways to do this. :-)