Beispiel #1
0
        public static Frame FlattenFromChexelProvider(ChexelProvider top, Frame bottom)
        {
            int xMax = bottom.width + bottom.xOffset;
            int yMax = bottom.height + bottom.yOffset;

            Frame toReturn = new Frame(xMax, yMax, 0, 0);

            for (int x = 0; x < xMax; x++)
            {
                for (int y = 0; y < yMax; y++)
                {
                    Chexel toSet = new Chexel();

                    if (top.hasChexel(x, y))
                    {
                        toSet = top.getChexel(x, y);
                    }
                    else if (bottom.hasChexel(x, y))
                    {
                        toSet = bottom.getChexel(x, y);
                    }

                    toReturn.setChexel(x, y, toSet);
                }
            }

            return(toReturn);
        }
Beispiel #2
0
        public static Frame Flatten(Frame top, Frame bottom)
        {
            int xMaxTop = top.width + top.xOffset;
            int yMaxTop = top.height + top.yOffset;
            int xMaxBot = bottom.width + bottom.xOffset;
            int yMaxBot = bottom.height + bottom.yOffset;

            int xMax = xMaxTop > xMaxBot ? xMaxTop : xMaxBot;
            int yMax = yMaxTop > yMaxBot ? yMaxTop : yMaxBot;

            Frame toReturn = new Frame(xMax, yMax, 0, 0);

            for (int x = 0; x < xMax; x++)
            {
                for (int y = 0; y < yMax; y++)
                {
                    Chexel toSet = new Chexel();

                    if (top.hasChexel(x, y))
                    {
                        toSet = top.getChexel(x, y);
                    }
                    else if (bottom.hasChexel(x, y))
                    {
                        toSet = bottom.getChexel(x, y);
                    }

                    toReturn.setChexel(x, y, toSet);
                }
            }

            return(toReturn);
        }
Beispiel #3
0
 public void setChexel(int x, int y, Chexel chexel)
 {
     if (hasChexel(x, y))
     {
         forground[x, y]  = chexel.f;
         background[x, y] = chexel.b;
         text[x, y]       = chexel.t;
     }
 }
Beispiel #4
0
        public void Draw()
        {
            timer.Restart();

            flatten();

            Console.SetCursorPosition(0, 0);
            ConsoleColor currentBackground = Console.BackgroundColor;
            ConsoleColor currentForground  = Console.ForegroundColor;

            for (int y = 0; y < height; y++)
            {
                List <char> line = new List <char>();
                for (int x = 0; x < width; x++)
                {
                    char         toPrint = ' ';
                    ConsoleColor bToSet  = currentBackground;
                    ConsoleColor fToSet  = currentForground;

                    if ((x >= 0 && x < width) && (y >= 0 && y < height))
                    {
                        Chexel chexel = main.getChexel(x, y);

                        bToSet  = chexel.b;
                        fToSet  = chexel.f;
                        toPrint = chexel.t;

                        if (bToSet != currentBackground || fToSet != currentForground)
                        {
                            Console.Write((char[])line.ToArray());
                            line.Clear();

                            if (bToSet != currentBackground)
                            {
                                Console.BackgroundColor = bToSet;
                                currentBackground       = bToSet;
                            }

                            if (fToSet != currentForground)
                            {
                                Console.ForegroundColor = fToSet;
                                currentForground        = fToSet;
                            }
                        }
                    }

                    line.Add(toPrint);
                }

                Console.WriteLine((char[])line.ToArray());
            }

            timer.Stop();
            drawTime = timer.Elapsed;
        }