コード例 #1
0
 /// <summary>
 /// Limpa os dados de todos os campos.
 /// </summary>
 private void Clear()
 {
     BasicTab.Clear();
     StatTab.Clear();
     VitalTab.Clear();
     PhysicalTab.Clear();
     MagicTab.Clear();
     ExtraTab.Clear();
     ElementalTab.Clear();
     ResistTab.Clear();
 }
コード例 #2
0
 public FPSCounterComponent(Microsoft.Xna.Framework.Game game)
     : base(game)
 {
     surface = new Basic(30, 1)
     {
         DefaultBackground = Color.Black
     };
     surface.Clear();
     DrawOrder = 8;
     Global.GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
 }
コード例 #3
0
            public override void Draw(GameTime gameTime)
            {
                frameCounter++;
                surface.Clear();
                surface.Print(0, 0, $"fps: {this.frameRate}", Color.White, Color.Black);
                surface.Draw(gameTime.ElapsedGameTime);

                Global.GraphicsDevice.SetRenderTarget(null);
                Global.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone);
                Global.SpriteBatch.Draw(surface.LastRenderResult, Vector2.Zero, Color.White);
                Global.SpriteBatch.End();
            }
コード例 #4
0
        public static void ToSurface(this Texture2D image, Basic surface, Color[] cachedColorArray, 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 / surface.Font.Size.Y, (h) =>
                                                        //for (int h = 0; h < imageHeight / surface.Font.Size.Y; h++)
            {
                int startY = (h * surface.Font.Size.Y);
                //System.Threading.Tasks.Parallel.For(0, imageWidth / surface.Font.Size.X, (w) =>
                for (int w = 0; w < imageWidth / surface.Font.Size.X; w++)
                {
                    int startX = (w * surface.Font.Size.X);

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

                    for (int y = 0; y < surface.Font.Size.Y; y++)
                    {
                        for (int x = 0; x < surface.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 / (surface.Font.Size.X * surface.Font.Size.Y));
                    byte sg = (byte)(allG / (surface.Font.Size.X * surface.Font.Size.Y));
                    byte sb = (byte)(allB / (surface.Font.Size.X * surface.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);
                        }
                    }
                }
            }
                                                        );
        }
コード例 #5
0
        /// <summary>
        /// Returns a surface with the specified image rendered to it as characters.
        /// </summary>
        /// <param name="image">The image to render.</param>
        /// <returns>The surface.</returns>
        public Basic GetSurface(Texture2D image)
        {
            surface.Clear();

            image.GetData <Color>(pixels);

            System.Threading.Tasks.Parallel.For(0, surface.Width * surface.Height, (i) =>
                                                //for (int i = 0; i < surface.Width * surface.Height; i++)
            {
                int allR = 0;
                int allG = 0;
                int allB = 0;

                int min = i * fontPixels;
                int max = min + fontPixels;

                for (int pixel = min; pixel < max; pixel++)
                {
                    Color color = pixels[indexes[pixel]];

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

                // print our character
                byte sr = (byte)(allR / fontPixels);
                byte sg = (byte)(allG / fontPixels);
                byte sb = (byte)(allB / fontPixels);

                var newColor = new Color(sr, sg, sb);
                float sbri   = newColor.GetBrightness() * 255;


                Point surfacePoint = surface.GetPointFromIndex(i);
                if (UseBlockMode)
                {
                    if (sbri > 204)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 219, newColor); //█
                    }
                    else if (sbri > 152)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 178, newColor); //▓
                    }
                    else if (sbri > 100)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 177, newColor); //▒
                    }
                    else if (sbri > 48)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 176, newColor); //░
                    }
                    else
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
                else
                {
                    if (sbri > 230)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'#', newColor);
                    }
                    else if (sbri > 207)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'&', newColor);
                    }
                    else if (sbri > 184)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'$', newColor);
                    }
                    else if (sbri > 161)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'X', newColor);
                    }
                    else if (sbri > 138)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'x', newColor);
                    }
                    else if (sbri > 115)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'=', newColor);
                    }
                    else if (sbri > 92)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'+', newColor);
                    }
                    else if (sbri > 69)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)';', newColor);
                    }
                    else if (sbri > 46)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)':', newColor);
                    }
                    else if (sbri > 23)
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, (int)'.', newColor);
                    }
                    else
                    {
                        surface.SetGlyph(surfacePoint.X, surfacePoint.Y, 0, Color.Black);
                    }
                }
            }
                                                );

            return(surface);
        }