public void ConstructorToVector4(IPixel packedVector, float[] expectedVector4Components)
        {
            // Arrange
            int precision = 2;
            // using float array to work around a bug in xunit corruptint the state of any Vector4 passed as MemberData
            Vector4 expectedVector4 = new Vector4(expectedVector4Components[0], expectedVector4Components[1], expectedVector4Components[2], expectedVector4Components[3]);

            // Act
            Vector4 vector4 = packedVector.ToVector4();

            // Assert
            Assert.Equal(expectedVector4.X, vector4.X, precision);
            Assert.Equal(expectedVector4.Y, vector4.Y, precision);
            Assert.Equal(expectedVector4.Z, vector4.Z, precision);
            Assert.Equal(expectedVector4.W, vector4.W, precision);
        }
예제 #2
0
        public void FromVector4ToVector4(IPixel packedVector, float[] vector4ComponentsToPack)
        {
            // Arrange
            int     precision     = 2;
            Vector4 vector4ToPack = new Vector4(vector4ComponentsToPack[0], vector4ComponentsToPack[1], vector4ComponentsToPack[2], vector4ComponentsToPack[3]);

            packedVector.PackFromVector4(vector4ToPack);

            // Act
            Vector4 vector4 = packedVector.ToVector4();

            // Assert
            Assert.Equal(vector4ToPack.X, vector4.X, precision);
            Assert.Equal(vector4ToPack.Y, vector4.Y, precision);
            Assert.Equal(vector4ToPack.Z, vector4.Z, precision);
            Assert.Equal(vector4ToPack.W, vector4.W, precision);
        }
예제 #3
0
        public static IImageProcessingContext <TPixel> Tint <TPixel>(this IImageProcessingContext <TPixel> source, IPixel color, float amount = 1) where TPixel : struct, IPixel <TPixel>
        {
            var rgb = color.ToVector4() * amount;

            var filter = new Matrix4x4()
            {
                M11 = 1 - amount,
                M22 = 1 - amount,
                M33 = 1 - amount,
                M41 = rgb.X,
                M42 = rgb.Y,
                M43 = rgb.Z,
                M44 = 1
            };

            return(source.Filter(filter));
        }
예제 #4
0
 public _LerpColorSampler(ITextureSampler <float> source, IPixel odd, IPixel even)
 {
     _Source    = source;
     _OddColor  = odd.ToVector4();
     _EvenColor = even.ToVector4();
 }