Exemple #1
0
        protected override void OnStart()
        {
            //Draw symbol from char
            DrawChar(0, 0, '#', 15);
            //Draw symbol from short
            DrawPixel(2, 0, (short)Character.Medium, (short)(COLOR.FG_BLUE | COLOR.BG_RED));
            //Draw line
            DrawLine(1, 2, 3, 20, (short)Character.Full, (short)COLOR.FG_CYAN);
            //Draw line gradient
            DrawLineGradient(3, 2, 5, 20, (short)COLOR.FG_RED, (short)COLOR.FG_BLUE);
            //Draw text
            DrawText(4, 0, "This is text ..", (short)(COLOR.BG_YELLOW | COLOR.FG_BLUE));

            /*
             * Convert rgb color to ConsoleColor!
             */
            COLOR     cl;
            Character ch;

            ColorUtilites.GetConsoleColor(Color.Crimson, out ch, out cl);
            DrawRect(6, 2, 3, 3, (short)ch, (short)cl);
            //Draw rect
            DrawRect(11, 2, 4, 4, (short)Character.Full, (short)COLOR.FG_GREEN);
            //Draw cicrle
            DrawCircle(13, 15, 6, (short)'*', 12);
            //Draw triangle
            DrawTriangle(21, 41, 25, 0, 0, 25, (short)Character.Dark, (short)COLOR.FG_GREEN);

            FillRect(43, 0, 20, 20, (short)Character.Medium, (short)(COLOR.FG_YELLOW | COLOR.BG_BLUE));

            Apply();
        }
        protected override void OnStart()
        {
            var b = new Bitmap("image.jpg");

            bitmap = (Bitmap)FixedSize(b, Height, Width, false);

            for (int x = 0; x < bitmap.Width; x++)
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    Character ch    = Character.Full;
                    COLOR     color = COLOR.FG_WHITE;
                    ColorUtilites.GetConsoleColor(bitmap.GetPixel(x, y), out ch, out color);

                    DrawPixel((short)x, (short)y, (short)ch, (short)color);
                }
            }

            Apply();
        }
Exemple #3
0
        public void DrawLineGradient(short x, short y, short x2, short y2, short color1, short color2)
        {
            int   w = x2 - x;
            int   h = y2 - y;
            short dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0;

            if (w < 0)
            {
                dx1 = -1;
            }
            else if (w > 0)
            {
                dx1 = 1;
            }
            if (h < 0)
            {
                dy1 = -1;
            }
            else if (h > 0)
            {
                dy1 = 1;
            }
            if (w < 0)
            {
                dx2 = -1;
            }
            else if (w > 0)
            {
                dx2 = 1;
            }
            int longest  = Math.Abs(w);
            int shortest = Math.Abs(h);

            if (!(longest > shortest))
            {
                longest  = Math.Abs(h);
                shortest = Math.Abs(w);
                if (h < 0)
                {
                    dy2 = -1;
                }
                else if (h > 0)
                {
                    dy2 = 1;
                }
                dx2 = 0;
            }
            int numerator = longest >> 1;

            Color one = ((COLOR)color1).GetRGB();
            Color two = ((COLOR)color2).GetRGB();

            for (int i = 0; i <= longest; i++)
            {
                COLOR     cl;
                Character ch;

                ColorUtilites.CombineTwoColors(((COLOR)color1), ((COLOR)color2), (float)i / longest, out ch, out cl);

                DrawPixel(x, y, (short)ch, (short)cl);
                numerator += shortest;
                if (!(numerator < longest))
                {
                    numerator -= longest;
                    x         += dx1;
                    y         += dy1;
                }
                else
                {
                    x += dx2;
                    y += dy2;
                }
            }
        }