Beispiel #1
0
        public static string BuildGraph(int[] stats, char rank, string name)
        {
            using (Image <Rgba32> img = Image.Load("Data/template.png"))
            {
                IPath userGraph = BuildPath(stats);
                var   DRanks    = RPClass.Users.Where(x => x.GetRank().Contains(rank)).Where(x => x.Stats.Melee != 0).Select(x => x.Stats.GetList());

                int[] total = new int[9];
                int[] data  = new int[9];
                foreach (var array in DRanks)
                {
                    for (int i = 0; i < 9; i++)
                    {
                        total[i] += array[i];
                    }
                }
                for (int i = 0; i < 9; i++)
                {
                    data[i] = total[i] / DRanks.Count();
                }
                IPath rankGraph = BuildPath(data);
                img.Mutate(x =>
                           x.Fill(Brushes.Percent20(Rgba32.Red), rankGraph)
                           .Draw(Rgba32.Red, 6, rankGraph)
                           .Fill(Brushes.Percent20(Rgba32.Blue), userGraph)
                           .Draw(Rgba32.Blue, 6, userGraph));

                string fileName = Extensions.RandomString(5);
                img.Save($"Data/{fileName}.png");
                return($"Data/{fileName}.png");
            }
        }
Beispiel #2
0
        public static IBrush GetBrush(this Cmdlet cmdlet, Brush brushType, string colorString, string backgroundString)
        {
            Rgba32 rgbaColor      = cmdlet.ParseColor(colorString);
            Rgba32 rgbaBackground = cmdlet.ParseColor(backgroundString);
            Color  color          = new Color(rgbaColor);
            Color  background     = new Color(rgbaBackground);

            switch (brushType)
            {
            case Brush.Horizontal:
                return(Brushes.Horizontal(color, background));

            case Brush.Vertical:
                return(Brushes.Vertical(color, background));

            case Brush.ForwardDiagonal:
                return(Brushes.ForwardDiagonal(color, background));

            case Brush.BackwardDiagonal:
                return(Brushes.BackwardDiagonal(color, background));

            case Brush.Min:
                return(Brushes.Min(color, background));

            case Brush.Percent10:
                return(Brushes.Percent10(color, background));

            case Brush.Percent20:
                return(Brushes.Percent20(color, background));

            default:
                return(Brushes.Solid(color));
            }
        }
Beispiel #3
0
 public void ImageShouldBeFloodFilledWithPercent20_transparent()
 {
     Test("Percent20_Transparent", Color.Blue, Brushes.Percent20(Color.HotPink),
          new Color[, ] {
         { Color.HotPink, Color.Blue, Color.Blue, Color.Blue },
         { Color.Blue, Color.Blue, Color.HotPink, Color.Blue },
         { Color.HotPink, Color.Blue, Color.Blue, Color.Blue },
         { Color.Blue, Color.Blue, Color.HotPink, Color.Blue }
     });
 }
Beispiel #4
0
 public void ImageShouldBeFloodFilledWithPercent20()
 {
     Test("Percent20", Color.Blue, Brushes.Percent20(Color.HotPink, Color.LimeGreen),
          new Color[, ] {
         { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
         { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen },
         { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
         { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen }
     });
 }
Beispiel #5
0
 public void ImageShouldBeFloodFilledWithPercent20_transparent()
 {
     Test("Percent20_Transparent", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink),
          new Rgba32[, ] {
         { Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue },
         { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue },
         { Rgba32.HotPink, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue },
         { Rgba32.Blue, Rgba32.Blue, Rgba32.HotPink, Rgba32.Blue }
     });
 }
Beispiel #6
0
 public void ImageShouldBeFloodFilledWithPercent20()
 {
     Test("Percent20", Rgba32.Blue, Brushes.Percent20(Rgba32.HotPink, Rgba32.LimeGreen),
          new Rgba32[, ] {
         { Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen },
         { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen },
         { Rgba32.HotPink, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen },
         { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.HotPink, Rgba32.LimeGreen }
     });
 }
Beispiel #7
0
        public void ImageShouldBeFloodFilledWithPercent20()
        {
            var expectedPattern = new Rgba32[, ]
            {
                { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
                { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen },
                { Color.HotPink, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
                { Color.LimeGreen, Color.LimeGreen, Color.HotPink, Color.LimeGreen }
            };

            this.Test(
                "Percent20",
                Color.Blue,
                Brushes.Percent20(Color.HotPink, Color.LimeGreen),
                expectedPattern);
        }
Beispiel #8
0
        public void ImageShouldBeFloodFilledWithPercent20_transparent()
        {
            var expectedPattern = new Rgba32[, ]
            {
                { Color.HotPink, Color.Blue, Color.Blue, Color.Blue },
                { Color.Blue, Color.Blue, Color.HotPink, Color.Blue },
                { Color.HotPink, Color.Blue, Color.Blue, Color.Blue },
                { Color.Blue, Color.Blue, Color.HotPink, Color.Blue }
            };

            this.Test(
                "Percent20_Transparent",
                Color.Blue,
                Brushes.Percent20(Color.HotPink),
                expectedPattern);
        }
        public static Image <Rgba32> GetDifferenceImage(Image <Rgba32> expected, byte[,] differences)
        {
            var             differenceImage = expected.Clone();
            IBrush <Rgba32> brush           = Brushes.Percent20(Rgba32.Magenta);

            for (var y = 0; y < differences.GetLength(1); y++)
            {
                for (var x = 0; x < differences.GetLength(0); x++)
                {
                    var cellValue = differences[x, y];
                    if (cellValue > 0)
                    {
                        var cellRectangle =
                            new RectangleF((float)x * CellSize, (float)y * CellSize, CellSize, CellSize);
                        differenceImage.Mutate(i => i.Fill(new GraphicsOptions(), brush, cellRectangle));
                    }
                }
            }

            return(differenceImage);
        }
 /// <summary>
 /// Create as brush that will paint a Percent20 Hatch Pattern with
 /// in the specified foreground and background colors
 /// </summary>
 /// <param name="foreColor">Color of the foreground.</param>
 /// <param name="backColor">Color of the background.</param>
 /// <returns>A Brush</returns>
 public static PatternBrush Percent20(Color foreColor, Color backColor)
 => new PatternBrush(Brushes <Color> .Percent20(foreColor, backColor));
 /// <summary>
 /// Create as brush that will paint a Percent20 Hatch Pattern with
 /// in the specified foreground color and a transparent background
 /// </summary>
 /// <param name="foreColor">Color of the foreground.</param>
 /// <returns>A Brush</returns>
 public static PatternBrush Percent20(Color foreColor)
 => new PatternBrush(Brushes <Color> .Percent20(foreColor, Color.Transparent));