Beispiel #1
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 #2
0
        public void ImageShouldBeOverlayedByFilledPolygonWithPattern()
        {
            string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");

            Vector2[] simplePath = new[] {
                new Vector2(10, 10),
                new Vector2(200, 150),
                new Vector2(50, 300)
            };

            using (Image image = new Image(500, 500))
            {
                using (FileStream output = File.OpenWrite($"{path}/Pattern.png"))
                {
                    image
                    .FillPolygon(Brushes.Horizontal(Color.HotPink), simplePath, new GraphicsOptions(true))
                    .Save(output);
                }

                using (PixelAccessor <Color> sourcePixels = image.Lock())
                {
                    Assert.Equal(Color.HotPink, sourcePixels[81, 145]);
                }
            }
        }
Beispiel #3
0
 public void ImageShouldBeFloodFilledWithHorizontal_transparent()
 {
     Test("Horizontal_Transparent", Color.Blue, Brushes.Horizontal(Color.HotPink),
          new Color[, ] {
         { Color.Blue, Color.Blue, Color.Blue, Color.Blue },
         { Color.HotPink, Color.HotPink, Color.HotPink, Color.HotPink },
         { Color.Blue, Color.Blue, Color.Blue, Color.Blue },
         { Color.Blue, Color.Blue, Color.Blue, Color.Blue }
     });
 }
Beispiel #4
0
 public void ImageShouldBeFloodFilledWithHorizontal()
 {
     Test("Horizontal", Color.Blue, Brushes.Horizontal(Color.HotPink, Color.LimeGreen),
          new Color[, ] {
         { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
         { Color.HotPink, Color.HotPink, Color.HotPink, Color.HotPink },
         { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
         { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen }
     });
 }
Beispiel #5
0
 public void ImageShouldBeFloodFilledWithHorizontal_transparent()
 {
     Test("Horizontal_Transparent", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink),
          new Rgba32[, ] {
         { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue },
         { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink },
         { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue },
         { Rgba32.Blue, Rgba32.Blue, Rgba32.Blue, Rgba32.Blue }
     });
 }
Beispiel #6
0
 public void ImageShouldBeFloodFilledWithHorizontal()
 {
     Test("Horizontal", Rgba32.Blue, Brushes.Horizontal(Rgba32.HotPink, Rgba32.LimeGreen),
          new Rgba32[, ] {
         { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen },
         { Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink, Rgba32.HotPink },
         { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen },
         { Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen, Rgba32.LimeGreen }
     });
 }
        public void FillPolygon_Pattern <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            SixLabors.Primitives.PointF[] simplePath =
            {
                new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300)
            };
            var color = Color.Yellow;

            var brush = Brushes.Horizontal(color);

            provider.RunValidatingProcessorTest(
                c => c.FillPolygon(brush, simplePath),
                appendSourceFileOrDescription: false);
        }
Beispiel #8
0
        public void ImageShouldBeFloodFilledWithHorizontal_transparent()
        {
            var expectedPattern = new Rgba32[, ]
            {
                { Color.Blue, Color.Blue, Color.Blue, Color.Blue },
                { Color.HotPink, Color.HotPink, Color.HotPink, Color.HotPink },
                { Color.Blue, Color.Blue, Color.Blue, Color.Blue },
                { Color.Blue, Color.Blue, Color.Blue, Color.Blue }
            };

            this.Test(
                "Horizontal_Transparent",
                Color.Blue,
                Brushes.Horizontal(Color.HotPink),
                expectedPattern);
        }
Beispiel #9
0
        public void ImageShouldBeFloodFilledWithHorizontal()
        {
            var expectedPattern = new Rgba32[, ]
            {
                { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
                { Color.HotPink, Color.HotPink, Color.HotPink, Color.HotPink },
                { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen },
                { Color.LimeGreen, Color.LimeGreen, Color.LimeGreen, Color.LimeGreen }
            };

            this.Test(
                "Horizontal",
                Color.Blue,
                Brushes.Horizontal(Color.HotPink, Color.LimeGreen),
                expectedPattern);
        }
        public void ImageShouldBeOverlayedByFilledPolygonWithPattern()
        {
            string path       = TestEnvironment.CreateOutputDirectory("Drawing", "FilledPolygons");
            var    simplePath = new SixLabors.Primitives.PointF[] {
                new Vector2(10, 10),
                new Vector2(200, 150),
                new Vector2(50, 300)
            };

            using (var image = new Image <Rgba32>(500, 500))
            {
                image.Mutate(
                    x => x.FillPolygon(new GraphicsOptions(true), Brushes.Horizontal(Rgba32.HotPink), simplePath));
                image.Save($"{path}/Pattern.png");

                Buffer2D <Rgba32> sourcePixels = image.GetRootFramePixelBuffer();
                Assert.Equal(Rgba32.HotPink, sourcePixels[81, 145]);
            }
        }
Beispiel #11
0
        public void ImageShouldBeOverlayedByFilledPolygonWithPattern()
        {
            string path = this.CreateOutputDirectory("Drawing", "FilledPolygons");

            SixLabors.Primitives.PointF[] simplePath = new SixLabors.Primitives.PointF[] {
                new Vector2(10, 10),
                new Vector2(200, 150),
                new Vector2(50, 300)
            };

            using (Image <Rgba32> image = new Image <Rgba32>(500, 500))
            {
                image
                .FillPolygon(Brushes.Horizontal(Rgba32.HotPink), simplePath, new GraphicsOptions(true))
                .Save($"{path}/Pattern.png");

                using (PixelAccessor <Rgba32> sourcePixels = image.Lock())
                {
                    Assert.Equal(Rgba32.HotPink, sourcePixels[81, 145]);
                }
            }
        }
 /// <summary>
 /// Create as brush that will paint a Horizontal 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 Horizontal(Color foreColor, Color backColor)
 => new PatternBrush(Brushes <Color> .Horizontal(foreColor, backColor));
 /// <summary>
 /// Create as brush that will paint a Horizontal 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 Horizontal(Color foreColor)
 => new PatternBrush(Brushes <Color> .Horizontal(foreColor, Color.Transparent));