Example #1
0
        public void drawRectangle(Rectangle place, Color color, string style)
        {
            PixColor clr = getClosestColor(color);

            clr.ApplyColorsToConsole();
            Console.BackgroundColor = ConsoleColor.Black;

            Console.SetCursorPosition(place.X, place.Y);
            Console.Write(style[2] + "".PadLeft(place.Width - 2, style[0]) + style[3]);
            for (int i = 1; i <= place.Height - 1; i++)
            {
                Console.SetCursorPosition(place.X, place.Y + i);
                Console.Write(style[1]);
                Console.SetCursorPosition(place.X + place.Width - 1, place.Y + i);
                Console.Write(style[1]);
            }
            Console.SetCursorPosition(place.X, place.Y + place.Height);
            Console.Write(style[4] + "".PadLeft(place.Width - 2, style[0]) + style[5]);
            //Console.ResetColor();
        }
Example #2
0
        PixColor getClosestColor(Color clr)
        {
            PixColor res      = new PixColor(' ', 0, 0);
            int      bestDiff = clr.R + clr.G + clr.B;

            foreach (PixColor px in pallete)
            {
                //int main = (clr.R > clr.G && clr.R > clr.B) ? 1 : (clr.G > clr.B) ? 2 : 3;
                int diff =
                    Math.Abs(px._colorApproach.R - clr.R)    //* (main == 1 ? 2 : 1)
                    + Math.Abs(px._colorApproach.G - clr.G)  //* (main == 2 ? 2 : 1)
                    + Math.Abs(px._colorApproach.B - clr.B); //* (main == 3 ? 2 : 1);
                if (diff >= bestDiff)
                {
                    continue;
                }
                bestDiff = diff;
                res      = px;
            }
            return(res);
        }
Example #3
0
        public void drawTestSquare(Rectangle place)
        {
            Color    lastColor = Color.Black;
            PixColor lastUsed  = new PixColor(' ', 0, 0, lastColor);

            for (int j = 0; j < place.Height; j++)
            {
                setCursor(place, j);
                for (int i = 0; i < place.Width; i++)
                {
                    Color pix = Color.FromArgb((int)(255.0 / place.Height * j), (int)(255.0 / place.Width * i), (int)(255.0 / (place.Width * place.Height) * i * j));
                    if (pix != lastColor)
                    {
                        lastUsed = getClosestColor(pix);
                    }

                    lastColor = pix;
                    lastUsed.Paint();
                }
            }
        }