Ejemplo n.º 1
0
        public void BlendFillColorOverBackround <TPixel>(
            TestImageProvider <TPixel> provider,
            bool triggerFillRegion,
            string newColorName,
            float alpha,
            PixelColorBlendingMode blenderMode,
            float blendPercentage)
            where TPixel : struct, IPixel <TPixel>
        {
            var vec = TestUtils.GetPixelOfNamedColor <RgbaVector>(newColorName).ToVector4();

            vec.W = alpha;

            TPixel fillColor = default;

            fillColor.PackFromVector4(vec);

            using (Image <TPixel> image = provider.GetImage())
            {
                TPixel bgColor = image[0, 0];

                var options = new GraphicsOptions(false)
                {
                    ColorBlendingMode = blenderMode, BlendPercentage = blendPercentage
                };

                if (triggerFillRegion)
                {
                    var region = new ShapeRegion(new RectangularPolygon(0, 0, 16, 16));

                    image.Mutate(c => c.Fill(options, new SolidBrush <TPixel>(fillColor), region));
                }
                else
                {
                    image.Mutate(c => c.Fill(options, new SolidBrush <TPixel>(fillColor)));
                }

                var testOutputDetails = new
                {
                    triggerFillRegion = triggerFillRegion,
                    newColorName      = newColorName,
                    alpha             = alpha,
                    blenderMode       = blenderMode,
                    blendPercentage   = blendPercentage
                };

                image.DebugSave(
                    provider,
                    testOutputDetails,
                    appendPixelTypeToFileName: false,
                    appendSourceFileOrDescription: false);

                PixelBlender <TPixel> blender = PixelOperations <TPixel> .Instance.GetPixelBlender(
                    blenderMode,
                    PixelAlphaCompositionMode.SrcOver);

                TPixel expectedPixel = blender.Blend(bgColor, fillColor, blendPercentage);

                image.ComparePixelBufferTo(expectedPixel);
            }
        }
Ejemplo n.º 2
0
        public void ShapeRegionWithPathRetainsShape()
        {
            var region = new ShapeRegion(this.pathMock.Object);

            Assert.Equal(this.pathMock.Object, region.Shape);
        }
Ejemplo n.º 3
0
        public void ShapeRegionWithPathRetainsShape()
        {
            ShapeRegion region = new ShapeRegion(pathMock.Object);

            Assert.Equal(shapeMock.Object, region.Shape);
        }