Beispiel #1
0
        private void BlitFadedCircle(Rect r, float val)
        {
            r.halfHeight = r.halfWidth;
            Point min = new Point {
                x = r.centreX - r.halfWidth, y = r.centreY - r.halfHeight
            };
            Point max = new Point {
                x = r.centreX + r.halfWidth, y = r.centreY + r.halfHeight
            };
            float maxDistSqr = r.halfWidth * r.halfWidth;

            for (int y = min.y; y < max.y; ++y)
            {
                for (int x = min.x; x < max.x; ++x)
                {
                    if (!GridUtilities.IsGridPosSafe(x, y, _width, _height))
                    {
                        continue;
                    }
                    float distSqr = GridUtilities.DistanceSqr(r.centreX, r.centreY, x, y);
                    float scale   = 1 - (distSqr / maxDistSqr);
                    if (scale < 0)
                    {
                        continue;
                    }
                    float addition = val * scale;
                    _map[GridUtilities.GridPosToIndex(x, y, _width)] += addition;
                }
            }
        }
Beispiel #2
0
 public int QueueSetPixel(int x, int y, float val)
 {
     if (!GridUtilities.IsGridPosSafe(x, y, _width, _height))
     {
         return(0);
     }
     _map[GridUtilities.GridPosToIndex(x, y, _width)] = val;
     return(0);
 }
Beispiel #3
0
        private void BlitSolidRect(Rect r, float val)
        {
            Point min = new Point {
                x = r.centreX - r.halfWidth, y = r.centreY - r.halfHeight
            };
            Point max = new Point {
                x = r.centreX + r.halfWidth, y = r.centreY + r.halfHeight
            };

            for (int y = min.y; y < max.y; ++y)
            {
                for (int x = min.x; x < max.x; ++x)
                {
                    if (!GridUtilities.IsGridPosSafe(x, y, _width, _height))
                    {
                        continue;
                    }
                    _map[GridUtilities.GridPosToIndex(x, y, _width)] += val;
                }
            }
        }
Beispiel #4
0
        public string DebugPrint()
        {
            StringBuilder sb = new StringBuilder(2048);

            for (int y = 0; y < _height; ++y)
            {
                for (int x = 0; x < _width; ++x)
                {
                    int   i   = GridUtilities.GridPosToIndex(x, y, _width);
                    float val = _map[i];
                    if (val != 0)
                    {
                        sb.Append(val.ToString("0.00"));
                    }
                    else
                    {
                        sb.Append("    ");
                    }
                    sb.Append(", ");
                }
                sb.Append("\n");
            }
            return(sb.ToString());
        }