private Color4 ColorForStatus(CircleStatus status)
        {
            if (status.MinDistance >= 2 * CircleRadius - Precision)
            {
                return(Color4.Green);
            }
            var relativeDistance = status.MinDistance / CircleRadius;

            return(Color4.Lerp(Color4.Red, Color4.Yellow, MathHelper.Clamp(MathHelper.Pow(relativeDistance - 1, 32), 0, 1)));
        }
Пример #2
0
        public void RefreshStatuses()
        {
            for (var i = 0; i < numCircles; i++)
            {
                var center            = frontCircleCenters[i];
                var closestDistanceSq = frontCirclesGrid.GetNeighborIndices(i)
                                        .Select(x => (frontCircleCenters[x] - center).LengthSquared())
                                        .MinOrNull() ?? float.MaxValue;
                frontCircleStatuses[i] = new CircleStatus(MathHelper.Sqrt(closestDistanceSq));
            }
            var distanceThreshold = circleRadius * 2 - precision;

            IsSuccessfulConfiguration = frontCircleStatuses.Take(numCircles).All(x => x.MinDistance > distanceThreshold);
        }