Ejemplo n.º 1
0
        public void RenderChixel(ushort x, ushort y, RenderOption option, PointerAdvance outmode)
        {
            Console.Title = "[Sx Sy]: [" + area.Source.X + " " + area.Source.Y + "]";

            Chixel final = new Chixel();
            Chixel current;

            // update the internal image of the screen
            if ((RenderOption.Record & option) == RenderOption.Record)
            {
                memory[x, y] = new Chixel(matrix[x, y]);
            }
            // do not render if chixel is not on the screen
            if ((Terminal.PointerX == area.Source.X + x && Terminal.PointerY == area.Source.Y + y) ||
                (area.Source.X + x <= Terminal.Width && area.Source.Y + y <= Terminal.Height))
            {
                Terminal.Pointer((ushort)(area.Source.X + x), (ushort)(area.Source.Y + y));
            }
            else
            {
                return;
            }
            // just-in-time opacity merging
            if (matrix[x, y].MeshColor.Opacity != Color.ARGB_MAX)
            {
                // override view level for opacity blending
                if ((RenderOption.Reset & option) == RenderOption.Reset)
                {
                    Terminal.Colors(Chixel.DEFAULT_FG.Console, Chixel.DEFAULT_BG.Console);
                    Terminal.Put(Chixel.EMPTY_GLYPH, (Terminal.OutputMode)outmode, GetHashCode());
                }
                current = new Chixel(Terminal.GlyphAt((ushort)(area.Source.X + x), (ushort)(area.Source.Y + y), VIEW_LEVEL),
                                     new Color(Terminal.ForeAt((ushort)(area.Source.X + x), (ushort)(area.Source.Y + y), VIEW_LEVEL)),
                                     new Color(Terminal.BackAt((ushort)(area.Source.X + x), (ushort)(area.Source.Y + y), VIEW_LEVEL)));

                final.MeshColor = Blend.Apply(matrix[x, y].MeshColor, current.MeshColor,
                                              Blend.DEFAULT_POS, Blend.DEFAULT_USE_GAMMA, Blend.DEFAULT_MODE);

                Terminal.Colors(final.Fore.Console, final.Back.Console);
                Terminal.Put(final.Glyph, (Terminal.OutputMode)outmode, GetHashCode());
            }
            else
            {
                Terminal.Colors(matrix[x, y].Fore.Console, matrix[x, y].Back.Console);
                Terminal.Put(matrix[x, y].Glyph, (Terminal.OutputMode)outmode, GetHashCode());
            }
            // return the render matrix to the internal image of the screen
            if ((RenderOption.Restore & option) == RenderOption.Restore)
            {
                matrix[x, y] = new Chixel(memory[x, y]);
            }
            // reset the chixels in the internal image
            if ((RenderOption.CleanUp & option) == RenderOption.CleanUp)
            {
                memory[x, y] = new Chixel();
            }
            // reset the chixels in the render matrix
            if ((RenderOption.Blank & option) == RenderOption.Blank)
            {
                matrix[x, y] = new Chixel();
            }
        }