コード例 #1
0
static float scoreTouchTarget(IntPoint touchPoint, int padding, IntRect boundingBox)
{
    if (boundingBox.isEmpty())
        return 0;

    float reciprocalPadding = 1.f / padding;
    float score = 1;

    IntSize distance = boundingBox.differenceToPoint(touchPoint);
    score *= std::max((padding - abs(distance.width())) * reciprocalPadding, 0.f);
    score *= std::max((padding - abs(distance.height())) * reciprocalPadding, 0.f);

    return score;
}