public override Anchor GetNearestAnchor(PointT p, int exitAngleMod8 = -1)
{
VectorT vec = p - Center, vecAbs = vec.Abs();
bool vert = vecAbs.Y / Size.Y > vecAbs.X / Size.X;
Coord frac = ((p.Y - Top) / (Bottom - Top)).PutInRange(0, 1);
Anchor a;
if (vert) {
frac = ((p.X - Left) / (Right - Left)).PutInRange(0, 1);
if (vec.Y > 0) // bottom
a = Anchor(() => new PointT(Left + frac * (Right - Left), Bottom), 7 << 5);
else // top
a = Anchor(() => new PointT(Left + frac * (Right - Left), Top), 7 << 1);
} else {
if (vec.X > 0) // right
a = Anchor(() => new PointT(Right, Top + frac * (Bottom - Top)), 0x83);
else // left
a = Anchor(() => new PointT(Left, Top + frac * (Bottom - Top)), 7 << 3);
}
return a;
}