예제 #1
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(1, 1, "Open Image");
            surface.Clear(new Rectangle(1, 2, Width - 2, 2));
            surface.Print(1, 2, Path);
        }
예제 #2
0
        protected override void DrawView(CellSurface surface)
        {
            base.DrawView(surface);

            surface.Print(2, 1, "Game Settings");

            surface.Print(2, 4, "Spell Editor Application:");
            surface.Print(2, 5, new ColoredString(SpellEditorPath, new Cell(Color.Gray, DefaultBackground)));

            surface.Print(2, 10, "Font Size:");
            surface.Clear(15, 10, 10);
            surface.Print(15, 10, new ColoredString(FontSizeName, Color.Gray, DefaultBackground));
        }
예제 #3
0
        public virtual void Draw(CellSurface surface)
        {
            surface.Clear(new Rectangle(0, 0, Position.Width, Position.Height));

            foreach (var control in controls)
            {
                if (!control.IsVisible)
                {
                    continue;
                }

                var controlSurface = surface.GetSubSurface(control.Position);
                control.Draw(controlSurface);
            }
        }
예제 #4
0
        public static void ToSurface(this Texture2D image, CellSurface surface, Color[] cachedColorArray, Font font, bool blockMode = false)
        {
            int imageWidth  = image.Width;
            int imageHeight = image.Height;

            image.GetData <Color>(cachedColorArray);

            surface.Clear();
            global::System.Threading.Tasks.Parallel.For(0, imageHeight / font.Size.Y, (h) =>
                                                        //for (int h = 0; h < imageHeight / font.Size.Y; h++)
            {
                int startY = (h * font.Size.Y);
                //System.Threading.Tasks.Parallel.For(0, imageWidth / font.Size.X, (w) =>
                for (int w = 0; w < imageWidth / font.Size.X; w++)
                {
                    int startX = (w * font.Size.X);

                    float allR = 0;
                    float allG = 0;
                    float allB = 0;

                    for (int y = 0; y < font.Size.Y; y++)
                    {
                        for (int x = 0; x < font.Size.X; x++)
                        {
                            int cY = y + startY;
                            int cX = x + startX;

                            Color color = cachedColorArray[cY * imageWidth + cX];

                            allR += color.R;
                            allG += color.G;
                            allB += color.B;
                        }
                    }

                    byte sr = (byte)(allR / (font.Size.X * font.Size.Y));
                    byte sg = (byte)(allG / (font.Size.X * font.Size.Y));
                    byte sb = (byte)(allB / (font.Size.X * font.Size.Y));

                    var newColor = new Color(sr, sg, sb);

                    float sbri = newColor.GetBrightness() * 255;

                    if (blockMode)
                    {
                        if (sbri > 204)
                        {
                            surface.SetGlyph(w, h, 219, newColor); //█
                        }
                        else if (sbri > 152)
                        {
                            surface.SetGlyph(w, h, 178, newColor); //▓
                        }
                        else if (sbri > 100)
                        {
                            surface.SetGlyph(w, h, 177, newColor); //▒
                        }
                        else if (sbri > 48)
                        {
                            surface.SetGlyph(w, h, 176, newColor); //░
                        }
                    }
                    else
                    {
                        if (sbri > 230)
                        {
                            surface.SetGlyph(w, h, (int)'#', newColor);
                        }
                        else if (sbri > 207)
                        {
                            surface.SetGlyph(w, h, (int)'&', newColor);
                        }
                        else if (sbri > 184)
                        {
                            surface.SetGlyph(w, h, (int)'$', newColor);
                        }
                        else if (sbri > 161)
                        {
                            surface.SetGlyph(w, h, (int)'X', newColor);
                        }
                        else if (sbri > 138)
                        {
                            surface.SetGlyph(w, h, (int)'x', newColor);
                        }
                        else if (sbri > 115)
                        {
                            surface.SetGlyph(w, h, (int)'=', newColor);
                        }
                        else if (sbri > 92)
                        {
                            surface.SetGlyph(w, h, (int)'+', newColor);
                        }
                        else if (sbri > 69)
                        {
                            surface.SetGlyph(w, h, (int)';', newColor);
                        }
                        else if (sbri > 46)
                        {
                            surface.SetGlyph(w, h, (int)':', newColor);
                        }
                        else if (sbri > 23)
                        {
                            surface.SetGlyph(w, h, (int)'.', newColor);
                        }
                    }
                }
            }
                                                        );
        }