Beispiel #1
0
        public static BitmapBits DrawLayout(SphereType[,] layout, int gridsize, Rectangle?bounds = null)
        {
            int        stX       = bounds?.X ?? 0;
            int        stY       = bounds?.Y ?? 0;
            int        width     = bounds?.Width ?? layout.GetLength(0);
            int        height    = bounds?.Height ?? layout.GetLength(1);
            int        off       = (gridsize - 24) / 2;
            BitmapBits layoutbmp = new BitmapBits(width * gridsize, height * gridsize);

            for (int y = -gridsize / 2; y < layoutbmp.Height; y += gridsize * 2)
            {
                bool row = ((stX & 1) == 1) ^ ((stY & 1) == 1);
                for (int x = -gridsize / 2; x < layoutbmp.Width; x += gridsize)
                {
                    layoutbmp.FillRectangle(1, x, row ? y : y + gridsize, gridsize, gridsize);
                    row = !row;
                }
            }
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    SphereType sp = layout[x + stX, y + stY];
                    if ((sp & ~SphereType.RingFlag) != SphereType.Empty)
                    {
                        layoutbmp.DrawBitmapComposited(SphereBmps[sp], x * gridsize + off, y * gridsize + off);
                    }
                }
            }
            return(layoutbmp);
        }
Beispiel #2
0
        public static BitmapBits DrawLayout(SphereType?[,] layout, int gridsize)
        {
            int        width     = layout.GetLength(0);
            int        height    = layout.GetLength(1);
            int        off       = (gridsize - 24) / 2;
            BitmapBits layoutbmp = new BitmapBits(width * gridsize, height * gridsize);

            for (int y = -gridsize / 2; y < layoutbmp.Height; y += gridsize * 2)
            {
                for (int x = -gridsize / 2; x < layoutbmp.Width; x += gridsize * 2)
                {
                    layoutbmp.FillRectangle(1, x, y, gridsize, gridsize);
                }
            }
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    SphereType?sp = layout[x, y];
                    if (sp.HasValue && (sp.Value & ~SphereType.RingFlag) != SphereType.Empty)
                    {
                        layoutbmp.DrawBitmapComposited(SphereBmps[sp.Value], x * gridsize + off, y * gridsize + off);
                    }
                }
            }
            return(layoutbmp);
        }