Exemple #1
0
        public void Write(ConsoleBitmap bitmap, TimeSpan rowDelay, TimeSpan characterDelay)
        {
            bitmap = bitmap.WithFilledBackground(BackgroundColor);

            System.Console.CursorVisible = false;
            System.Console.Clear();

            foreach (var row in bitmap.GetRows())
            {
                foreach (var bit in row)
                {
                    System.Console.ForegroundColor = bit.ForegroundColor;
                    System.Console.BackgroundColor = bit.BackgroundColor;
                    System.Console.Write(bit.Character);

                    if (characterDelay != TimeSpan.Zero)
                    {
                        Task.Delay(characterDelay).Wait();
                    }
                }

                System.Console.WriteLine();

                if (rowDelay != TimeSpan.Zero)
                {
                    Task.Delay(rowDelay).Wait();
                }
            }

            System.Console.BackgroundColor = BackgroundColor;
            System.Console.ForegroundColor = ForegroundColor;
            System.Console.Write(" ");
            System.Console.CursorVisible = true;
        }
        public ConsoleBitmap CombinedWith(int xOffset, int yOffset, ConsoleBitmap other)
        {
            var combinedWidth  = Math.Max(Width, xOffset + other.Width);
            var combinedHeight = Math.Max(Height, yOffset + other.Height);
            var combinedBits   = CreateBits(combinedWidth, combinedHeight);

            InsertBits(combinedBits, 0, 0, Width, Height, _bits);
            InsertBits(combinedBits, xOffset, yOffset, other.Width, other.Height, other._bits);
            return(new ConsoleBitmap(combinedWidth, combinedHeight, combinedBits));
        }
        public ConsoleBitmap WithInserted(int xOffset, int yOffset, ConsoleBitmap insertedBitmap)
        {
            var insertedWidth  = Math.Max(0, Math.Min(Width - xOffset, insertedBitmap.Width));
            var insertedHeight = Math.Max(0, Math.Min(Height - yOffset, insertedBitmap.Height));

            var bits = CopyBits(Width, Height, _bits);

            InsertBits(bits, xOffset, yOffset, insertedWidth, insertedHeight, insertedBitmap._bits);

            return(new ConsoleBitmap(Width, Height, bits));
        }