/// <inheritdoc />
            public override void Blend(Span <TPixel> destination, Span <TPixel> background, Span <TPixel> source, Span <float> amount)
            {
                Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length));
                Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length));
                Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length));

                using (Buffer <Vector4> buffer = new Buffer <Vector4>(destination.Length * 3))
                {
                    Span <Vector4> destinationSpan = buffer.Slice(0, destination.Length);
                    Span <Vector4> backgroundSpan  = buffer.Slice(destination.Length, destination.Length);
                    Span <Vector4> sourceSpan      = buffer.Slice(destination.Length * 2, destination.Length);

                    PixelOperations <TPixel> .Instance.ToVector4(background, backgroundSpan, destination.Length);

                    PixelOperations <TPixel> .Instance.ToVector4(source, sourceSpan, destination.Length);

                    for (int i = 0; i < destination.Length; i++)
                    {
                        destinationSpan[i] = PorterDuffFunctions.Xor(backgroundSpan[i], sourceSpan[i], amount[i]);
                    }

                    PixelOperations <TPixel> .Instance.PackFromVector4(destinationSpan, destination, destination.Length);
                }
            }
Esempio n. 2
0
 public static TPixel DarkenFunction(TPixel backdrop, TPixel source, float opacity)
 {
     return(ToPixel(PorterDuffFunctions.DarkenFunction(backdrop.ToVector4(), source.ToVector4(), opacity)));
 }
 /// <inheritdoc />
 public override TPixel Blend(TPixel background, TPixel source, float amount)
 {
     return(PorterDuffFunctions.Xor(background, source, amount));
 }
Esempio n. 4
0
 /// <inheritdoc />
 public override TPixel Blend(TPixel background, TPixel source, float amount)
 {
     return(PorterDuffFunctions <TPixel> .SubstractFunction(background, source, amount));
 }