示例#1
0
        public override void Render(Label label)
        {
            if (string.IsNullOrEmpty(label.Text))
            {
                return;
            }
            var lines       = label.RenderLines;
            int maxLineSize = lines
                              .Select(s => s.Count())
                              .Max();

            Vector2 size = label.Size;

            size.X = Math.Min(maxLineSize, size.X);
            size.Y = Math.Min(lines.Count, size.Y);
            Vector2      lineSize = new Vector2(size.X, 1);
            var          bounds   = BoundsCalculator.Calculate(label, size);
            ConsoleColor color    = GetColor(label);

            int lineI = 0;

            for (int y = bounds.YMin; y < bounds.YMax; y++)
            {
                lineSize.X = lines[lineI].Length;
                var lineBounds = BoundsCalculator.Calculate(new Vector2(label.Position.X, y), label.Pivot, lineSize);
                int i          = 0;
                for (int x = lineBounds.XMin; x < lineBounds.XMax; x++)
                {
                    SetPixel(x, y, lines[lineI][i++], color);
                }
                lineI++;
            }

            FinalizeRender(label);
        }
示例#2
0
        public override void Render(Rectangle rectangle)
        {
            var          bounds = BoundsCalculator.Calculate(rectangle, rectangle.Size);
            ConsoleColor color  = GetColor(rectangle);

            for (int y = bounds.YMin; y < bounds.YMax; y++)
            {
                for (int x = bounds.XMin; x < bounds.XMax; x++)
                {
                    SetPixel(x, y, rectangle.Character, color);
                }
            }
            FinalizeRender(rectangle);
        }
示例#3
0
        public override void Render(Frame frame)
        {
            char         c      = frame.Character;
            var          bounds = BoundsCalculator.Calculate(frame, frame.Size);
            ConsoleColor color  = GetColor(frame);

            for (int x = bounds.XMin; x < bounds.XMax; x++)
            {
                SetPixel(x, bounds.YMin, c, color);
                SetPixel(x, bounds.YMax - 1, c, color);
            }
            for (int y = bounds.YMin; y < bounds.YMax; y++)
            {
                SetPixel(bounds.XMin, y, c, color);
                SetPixel(bounds.XMax - 1, y, c, color);
            }

            FinalizeRender(frame);
        }