示例#1
0
        public static void renderCircleSlowNotAntialiased(Map2dFloat map, int x, int y, float radius)
        {
            for (int relativeY = (int)-radius; relativeY < (int)radius; relativeY++)
            {
                for (int relativeX = (int)-radius; relativeX < (int)radius; relativeX++)
                {
                    float distance = (float)Math.Sqrt(relativeX * relativeX + relativeY * relativeY);

                    // anti aliasing
                    float value = distance < radius ? 1.0f : 0.0f; // no antialiasing

                    if (value == 0.0f)
                    {
                        continue;
                    }

                    if (!map.isInRange(y + relativeY, x + relativeX))
                    {
                        continue;
                    }

                    map[y + relativeY, x + relativeX] = value;
                }
            }
        }
示例#2
0
        public float sample(Map2dFloat map, int offsetY, int offsetX)
        {
            float sum = 0.0f;

            for (int relativeY = 0; relativeY < size; relativeY++)
            {
                for (int relativeX = 0; relativeX < size; relativeX++)
                {
                    int x = offsetX + relativeOffsetOfTopLeftCornerX + relativeX;
                    int y = offsetY + relativeOffsetOfTopLeftCornerY + relativeY;

                    if (map.isInRange(y, x))
                    {
                        sum += map[y, x];
                    }
                }
            }

            sum = sum / (float)(size * size);
            return(sum);
        }