Пример #1
0
        private void RenderBoardAction(Vector2i position, int actionIndex)
        {
            Graphics.FillRectangle(RawColor.FromRGB(0xC57B10), Square(position, 0.4f));
            CreateBoardAction action        = (CreateBoardAction)Tree.Replay.Actions[actionIndex];
            Vector2f          pixelPosition = ToGraphic(new Vector2f(position.X, position.Y));

            if (action.Width == action.Height)
            {
                DrawString(action.Width.ToString(), font, RawColor.Black, pixelPosition, new Vector2f(0.5f, 0.5f));
            }
        }
Пример #2
0
        RawColor[] RadiusColor(Pixels pix, Point center, int[,] radiusData, int maxRadius)
        {
            int[]      counts   = new int[maxRadius + 1];
            int[]      sumR     = new int[maxRadius + 1];
            int[]      sumG     = new int[maxRadius + 1];
            int[]      sumB     = new int[maxRadius + 1];
            RawColor[] result   = new RawColor[maxRadius + 1];
            int        halfSize = (radiusData.GetLength(0) - 1) / 2;
            int        dx       = halfSize - center.X;
            int        dy       = halfSize - center.Y;
            int        left     = Math.Max(0, center.X - halfSize);
            int        top      = Math.Max(0, center.Y - halfSize);
            int        right    = Math.Min(pix.Width, center.X + halfSize + 1);
            int        bottom   = Math.Min(pix.Height, center.Y + halfSize + 1);

            for (int y = top; y < bottom; y++)
            {
                for (int x = left; x < right; x++)
                {
                    RawColor c      = pix.Data[x, y];
                    int      radius = radiusData[x + dx, y + dy];
                    counts[radius]++;
                    sumR[radius] += c.R;
                    sumG[radius] += c.G;
                    sumB[radius] += c.B;
                }
            }
            RawColor undefined = RawColor.Transparent;

            for (int i = 0; i < maxRadius + 1; i++)
            {
                if (counts[i] == 0)
                {
                    result[i] = undefined;
                }
                else
                {
                    result[i] = RawColor.FromRGB(
                        (byte)(sumR[i] / counts[i]),
                        (byte)(sumG[i] / counts[i]),
                        (byte)(sumB[i] / counts[i]));
                }
            }
            return(result);
        }