//Render a cell at x,y coords
        public static void RenderCell(GridContext bgc, int x, int y)
        {
            IPainter  painter = new CPainter();
            const int cellSize = 12;
            ulong     color = bgc.Pen.Rgba;
            const int subSize = 8;
            const int tinSize = (cellSize - subSize);
            byte      r, g, b, a;

            RasterLib.RasterApi.Ulong2Rgba(color, out r, out g, out b, out a);

            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong(16, 16, 16, 255);
            painter.DrawHollowRect(bgc, x + tinSize, y, 0, x + cellSize - 1, y + subSize - 1, 0);

            int ir = r;
            int ig = g;
            int ib = b;

            //Top side
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawLine2D(bgc, x + tinSize, y + 1, x + subSize + 1, y + 1, 0);
            painter.DrawLine2D(bgc, x + tinSize - 1, y + 2, x + subSize, y + 2, 0);
            painter.DrawLine2D(bgc, x + tinSize - 2, y + 3, x + subSize - 1, y + 3, 0);

            //Front side
            ir           = r;
            ig           = g;
            ib           = b;
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawFastFillRect(bgc, x + 1, y + tinSize + 1, 0, x + subSize, y + subSize + 2, 0);

            //Right side
            ir           = r / 2;
            ig           = g / 2;
            ib           = b / 2;
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawLine2D(bgc, x + cellSize - 2, y + 2, x + cellSize - 2, y + subSize, 0);
            painter.DrawLine2D(bgc, x + cellSize - 3, y + 2, x + cellSize - 3, y + subSize, 0);
            painter.DrawLine2D(bgc, x + cellSize - 4, y + 3, x + cellSize - 4, y + subSize + 1, 0);

            //Front rect
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong(32, 32, 32, 255);
            painter.DrawHollowRect(bgc, x, y + tinSize, 0, x + subSize - 1, y + cellSize - 1, 0);

            //Lines
            painter.DrawLine2D(bgc, x, y + tinSize, x + tinSize, y, 0);
            painter.DrawLine2D(bgc, x + subSize - 1, y + tinSize, x + cellSize - 1, y, 0);
            painter.DrawLine2D(bgc, x + subSize - 1, y + cellSize - 1, x + cellSize - 1, y + subSize - 1, 0);
        }
        //Render a cell at x,y coords
        private static void RenderIsometricCellScaled(GridContext bgc, int x, int y, int cellWidth, int cellHeight)
        {
            IPainter painter = new CPainter();
            ulong    color   = bgc.Pen.Rgba;
            //const int subSize = 8;
            //const int tinSize = (cellSize - subSize);
            byte r, g, b, a;

            RasterLib.RasterApi.Ulong2Rgba(color, out r, out g, out b, out a);

            int ir = r;
            int ig = g;
            int ib = b;

            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);

            bool skipWire = false;

            if (cellWidth == 1 && cellHeight == 1)
            {
                painter.DrawPen(bgc, x, y, 0);
                return;
            }
            else if (cellWidth <= 4 && cellHeight <= 4)
            {
                skipWire = true;
            }

            cellWidth  = cellWidth * 2;
            cellHeight = cellHeight * 2;

            int Is11 = (cellHeight / 4) * 3 - 1;

            //Top Left
            painter.DrawFillTriangle2D(bgc,
                                       x + 1, y + cellHeight / 4,
                                       x + cellWidth / 2, y + 0,
                                       x + cellWidth / 2, y + cellHeight / 2);

            //Top Right
            painter.DrawFillTriangle2D(bgc,
                                       x + cellWidth, y + cellHeight / 4,
                                       x + cellWidth / 2, y + 0,
                                       x + cellWidth / 2 - 1, y + cellHeight / 2);

            //Left
            ir           = (byte)(r / 1.5);
            ig           = (byte)(g / 1.5);
            ib           = (byte)(b / 1.5);
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawFillTriangle2D(bgc,
                                       x + 0, y + cellHeight / 4,
                                       x + cellWidth / 2, y + cellHeight / 2,
                                       x + 0, y + Is11 + 1);

            painter.DrawFillTriangle2D(bgc,
                                       x + 0, y + Is11 + 1,
                                       x + cellWidth / 2, y + cellHeight / 2,
                                       x + cellWidth / 2, y + cellHeight);


            //right
            ir           = r / 2;
            ig           = g / 2;
            ib           = b / 2;
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawFillTriangle2D(bgc,
                                       x + cellWidth, y + cellHeight / 4,
                                       x + cellWidth / 2 + 1, y + cellHeight / 2,
                                       x + cellWidth / 2 + 1, y + cellHeight);

            painter.DrawFillTriangle2D(bgc,
                                       x + cellWidth, y + cellHeight / 4,
                                       x + cellWidth, y + Is11 + 1,
                                       x + cellWidth / 2 + 1, y + cellHeight);



            if (skipWire)
            {
                return;
            }

            ir = (byte)(r / 2.5);
            ig = (byte)(g / 2.5);
            ib = (byte)(b / 2.5);

            //Top side
            bgc.Pen.Rgba = RasterLib.RasterApi.Rgba2Ulong((byte)ir, (byte)ig, (byte)ib, 255);
            painter.DrawLine2D(bgc,
                               x + 0, y + cellWidth / 4,
                               x + cellWidth / 2 - 1, y + 0,
                               0);
            //Top right
            painter.DrawLine2D(bgc,
                               x + cellWidth / 2 - 1, y + 0,
                               x + cellWidth - 1, y + cellHeight / 4,
                               0);

            //ToCenter - Top
            painter.DrawLine2D(bgc,
                               x + 0, y + cellWidth / 4,
                               x + cellWidth / 2 - 1, y + cellHeight / 2,
                               0);
            //FromCenter - Top
            painter.DrawLine2D(bgc,
                               x + cellWidth / 2 - 1, y + cellHeight / 2,
                               x + cellWidth - 1, y + cellHeight / 4,
                               0);

            //Halfway

            //Left Side
            painter.DrawLine2D(bgc,
                               x + 0, y + cellWidth / 4,
                               x + 0, y + Is11,
                               0);
            //Right side
            painter.DrawLine2D(bgc,
                               x + cellWidth, y + cellHeight / 4,
                               x + cellWidth, y + Is11,
                               0);

            //Right Bottom
            painter.DrawLine2D(bgc,
                               x + cellWidth, y + Is11 + 1,
                               x + cellWidth / 2, y + cellHeight,
                               0);
            //Right Left
            painter.DrawLine2D(bgc,
                               x + cellWidth / 2, y + cellHeight,
                               x + 0, y + Is11 + 1,
                               0);
        }