Пример #1
0
 public Chixel(Chixel other)
 {
     this.Glyph           = other.Glyph;
     this.ForegroundColor = other.ForegroundColor;
     this.BackgroundColor = other.BackgroundColor;
     this.Dirty           = true;
 }
Пример #2
0
        public int DrawFrame()
        {
            bool forceDirty = false;
            int  amount     = 0;

            if (lastWindowWidth != Console.WindowWidth || lastWindowHeight != Console.WindowHeight)
            {
                if (_instance == this)
                {
                    Console.Clear();
                }
                forceDirty = true;
                reset++;

                lastWindowWidth  = Console.WindowWidth;
                lastWindowHeight = Console.WindowHeight;
            }

            for (int y = 0; y < Height; y++)
            {
                if (true /*y < Console.WindowHeight*/)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        if (true /*x < Console.WindowWidth*/)
                        {
                            Chixel ch = this.chixels[x, y];
                            if (ch != null && (ch.Dirty == true || forceDirty))
                            {
                                try{ Console.SetCursorPosition(x + Left, y + Top); }catch {}
                                Console.ForegroundColor = ch.ForegroundColor;
                                Console.BackgroundColor = ch.BackgroundColor;
                                Console.Write(ch.Glyph);
                                ch.Dirty = false;
                                amount++;
                            }
                        }
                    }
                }
            }
            return(amount);
        }
Пример #3
0
        public void SetChixel(int x, int y, Char c, ConsoleColor fg_color = ConsoleColor.White, ConsoleColor bg_color = ConsoleColor.Black)
        {
            x -= Left;
            y -= Top;
            // check that the chixel is actually changed
            // if so, update values and set dirty

            if (x < 0 || x >= Width || y < 0 || y >= Height)
            {
                //throw new Exception();
                return;
            }

            Chixel ch = this.chixels[x, y];

            if (ch != null && ch.Glyph == c && ch.ForegroundColor == fg_color && ch.BackgroundColor == bg_color)
            {
                // No change.
                return;
            }

            this.chixels[x, y] = new Chixel(c, fg_color, bg_color);
        }
Пример #4
0
 public void SetChixel(int x, int y, Chixel chixel)
 {
     SetChixel(x, y, chixel.Glyph, chixel.ForegroundColor, chixel.BackgroundColor);
 }
Пример #5
0
 public void Clear()
 {
     Console.Clear();
     chixels = new Chixel[this.Width, this.Height];
 }