public override void Draw(CompactGraphics g)
        {
            g.Draw(rendered, Bounds.x1, Bounds.y1);

            char[][]         image;
            ConsoleColor[][] background;
            ConsoleColor[][] forground;
            int h = Height / 2;
            int w = Width;

            image      = new char[h + 1][];
            background = new ConsoleColor[h + 1][];
            forground  = new ConsoleColor[h + 1][];

            for (int i = 0; i <= h; i++)
            {
                image[i]      = new char[w + 1];
                forground[i]  = new ConsoleColor[w + 1];
                background[i] = new ConsoleColor[w + 1];

                for (int j = 0; j <= w; j++)
                {
                    image[i][j]      = pFull;
                    forground[i][j]  = ConsoleColor.Black;
                    background[i][j] = ConsoleColor.Black;
                }
            }

            rendered = new TFrame(image, background, forground);
        }
        /// <summary>
        /// Initilises the Virtual screen.
        /// </summary>
        /// <param name="w">width of the screen</param>
        /// <param name="h">height of the screen</param>
        public CompactGraphics(int w, int h)
        {
            // Initilisation=================================
            int[] wh = ScreenTest(w, h);
            Console.SetWindowSize(wh[0], wh[1]);
            Console.SetBufferSize(wh[0], wh[1]);
            Console.CursorVisible = false;
            //Console.OutputEncoding = System.Text.Encoding.ASCII;
            currentFrame = new TFrame(w, h);
            frameQueue   = new Queue <TFrame>();
            buf          = new CharInfo[w * h];
            rect         = new SmallRect()
            {
                Left = 0, Top = 0, Right = (short)w, Bottom = (short)h
            };
            this.f = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);

            FPS_FrameGet = new FrameTimeDelegate(FTFPS);

            Height         = h;
            Width          = w;
            maxQueueLength = 3;
            //thread creation================================
            ThreadStart fpsth = new ThreadStart(updateFps);

            updateFpsThread = new Thread(fpsth);
            updateFpsThread.IsBackground = true;
            updateFpsThread.Start();

            ThreadStart thref = new ThreadStart(FrameUpdater);

            updateThread = new Thread(thref);
            updateThread.IsBackground = true;
            updateThread.Start();
        }
        /// <summary>
        /// Queues up the current frame.
        /// </summary>
        public void pushFrame()
        {
            if (frameQueue.Count < maxQueueLength)
            {
                frameQueue.Enqueue(currentFrame);
                currentFrame = new TFrame(Width, Height);
            }
            TimeToFrame = Math.Max(0, DateTime.Now.Millisecond - timeOfLastFrame);

            Thread.Sleep(FrameTime);
            timeOfLastFrame = System.DateTime.Now.Millisecond;
        }
 internal void Draw(TFrame frame, int x, int y, ConsoleColor alphaKey = ConsoleColor.Black)
 {
     for (int i = 0; i < frame.image[0].Length; i++)
     {
         for (int j = 0; j < frame.image.Length; j++)
         {
             if (frame.image[j][i] != '\0')
             {
                 Draw(frame.image[j][i], frame.forground[j][i], x + i, y + j);
             }
             if (frame.background[j][i] != alphaKey)
             {
                 DrawBackground(frame.background[j][i], x + i, y + j);
             }
         }
     }
 }
        /// <summary>
        /// Updates the screen by writing to the standard output.
        /// </summary>
        /// <param name="screen">The frame to draw</param>
        private void update(TFrame screen)
        {
            if (!f.IsInvalid)
            {
                for (int i = 0; i < screen.framePallet.Length; i++)
                {
                    var tmp = !screen.framePallet[i].IsEmpty ? ExtendedColors.SetColor((ConsoleColor)i, screen.framePallet[i]) : i;
                }

                int y, x;
                //generate the buffer
                for (int i = 0; i < buf.Length; ++i)
                {
                    y = (int)i / Width;
                    x = i % Width;
                    buf[i].Attributes       = (short)((int)screen.forground[y][x] | (((int)screen.background[y][x]) << 4));
                    buf[i].Char.UnicodeChar = screen.image[y][x];
                }
                //push it.
                bool b = WriteConsoleOutput(this.f, buf,
                                            new Coord()
                {
                    X = (short)Width, Y = (short)Height
                },
                                            new Coord()
                {
                    X = 0, Y = 0
                },
                                            ref rect);
                frame_Counter++;
            }
            else
            {
                Console.SetCursorPosition(0, 0);
                Console.WriteLine("Console output handel is invalid");
            }
        }