/// <summary> /// Puts a rectangle in the buffer at its location, with the specified /// border. /// </summary> /// <param name="rect">The rectangle</param> /// <param name="borders">The rectangle's borders</param> private void PutRectangle(Rectangle rect, uint borders) { if ((borders & TOP) != 0) { LineHelper.PutLineHorizontal(CharBuffer, rect.Left, rect.Top, rect.Width + 1); } if ((borders & BOTTOM) != 0) { LineHelper.PutLineHorizontal(CharBuffer, rect.Left, rect.Top + rect.Height, rect.Width + 1); } if ((borders & LEFT) != 0) { LineHelper.PutLineVertical(CharBuffer, rect.Left, rect.Top, rect.Height + 1); } if ((borders & RIGHT) != 0) { LineHelper.PutLineVertical(CharBuffer, rect.Left + rect.Width, rect.Top, rect.Height + 1); } }
/// <summary> /// This algorithm draws the buffer character by character. Only draws /// the characters which are valid (ie != 0). /// </summary> /// <param name="buffer">The buffer to draw to</param> private void SlowDraw(IConsole buffer) { // optimization because system calls are expensive // somehow these were eating more cpu than the putcharacter int width = buffer.BufferWidth; int height = buffer.BufferHeight; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { uint code = CharBuffer [x, y]; if (code != 0) { short ch = buffer.SupportsComplex ? LineHelper.GetUnicodeChar(code): LineHelper.GetAsciiChar(code); buffer.PutCharacter(x, y, (int)ch); } } } }