コード例 #1
0
        /// <inheritdoc />
        public override void Blend(BufferSpan <TPixel> destination, BufferSpan <TPixel> background, BufferSpan <TPixel> source, BufferSpan <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))
            {
                BufferSpan <Vector4> destinationSpan = buffer.Slice(0, destination.Length);
                BufferSpan <Vector4> backgroundSpan  = buffer.Slice(destination.Length, destination.Length);
                BufferSpan <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.HardLightFunction(backgroundSpan[i], sourceSpan[i], amount[i]);
                }

                PixelOperations <TPixel> .Instance.PackFromVector4(destinationSpan, destination, destination.Length);
            }
        }
コード例 #2
0
 public static TPixel HardLightFunction(TPixel backdrop, TPixel source, float opacity)
 {
     return(ToPixel(PorterDuffFunctions.HardLightFunction(backdrop.ToVector4(), source.ToVector4(), opacity)));
 }
コード例 #3
0
 /// <inheritdoc />
 public override TPixel Blend(TPixel background, TPixel source, float amount)
 {
     return(PorterDuffFunctions <TPixel> .HardLightFunction(background, source, amount));
 }