示例#1
0
文件: PPMTests.cs 项目: bangush/Pyxis
        public void MustBePPMTypeThreeToImport()
        {
            var ppm    = @"P32
1 1
255
0 0 0";
            var action = new Action(() => PPM.Parse(ppm));

            action.Should().Throw <FileLoadException>();
        }
示例#2
0
文件: PPMTests.cs 项目: bangush/Pyxis
        public void HandlesColorDataOnDifferentLines()
        {
            var ppm    = @"P3
1 1
255
51
153

204";
            var canvas = PPM.Parse(ppm);

            canvas.PixelAt(0, 0).Should().Be(new Color(0.2f, 0.6f, 0.8f));
        }
示例#3
0
文件: PPMTests.cs 项目: bangush/Pyxis
        public void CreatesCanvasWithProperDimensions()
        {
            var ppm    = @"P3
10 2
255
0 0 0  0 0 0  0 0 0  0 0 0  0 0 0
0 0 0  0 0 0  0 0 0  0 0 0  0 0 0
0 0 0  0 0 0  0 0 0  0 0 0  0 0 0
0 0 0  0 0 0  0 0 0  0 0 0  0 0 0";
            var canvas = PPM.Parse(ppm);

            canvas.Width.Should().Be(10);
            canvas.Height.Should().Be(2);
        }
示例#4
0
文件: PPMTests.cs 项目: bangush/Pyxis
        public void HandlesComments()
        {
            var ppm    = @"P3
# this is a comment
2 1
# this, too
255
# another comment
255 255 255
# oh, no, comments in the pixel data!
255 0 255";
            var canvas = PPM.Parse(ppm);

            canvas.PixelAt(0, 0).Should().Be(new Color(1, 1, 1));
            canvas.PixelAt(1, 0).Should().Be(new Color(1, 0, 1));
        }
示例#5
0
文件: PPMTests.cs 项目: bangush/Pyxis
        public void ProperlyScalesPixelColor()
        {
            var ppm    = @"P3
4 3
255
255 127 0  0 127 255  127 255 0  255 255 255
0 0 0  255 0 0  0 255 0  0 0 255
255 255 0  0 255 255  255 0 255  127 127 127";
            var canvas = PPM.Parse(ppm);

            canvas.PixelAt(0, 0).Should().Be(new Color(1, 0.498f, 0));
            canvas.PixelAt(3, 0).Should().Be(new Color(1, 1, 1));
            canvas.PixelAt(2, 1).Should().Be(new Color(0, 1, 0));
            canvas.PixelAt(0, 2).Should().Be(new Color(1, 1, 0));
            canvas.PixelAt(3, 2).Should().Be(new Color(0.498f, 0.498f, 0.498f));
        }
示例#6
0
        public void ReturnsColorByUV()
        {
            var ppm     = @"P3
10 10
10
0 0 0  1 1 1  2 2 2  3 3 3  4 4 4  5 5 5  6 6 6  7 7 7  8 8 8  9 9 9
1 1 1  2 2 2  3 3 3  4 4 4  5 5 5  6 6 6  7 7 7  8 8 8  9 9 9  0 0 0
2 2 2  3 3 3  4 4 4  5 5 5  6 6 6  7 7 7  8 8 8  9 9 9  0 0 0  1 1 1
3 3 3  4 4 4  5 5 5  6 6 6  7 7 7  8 8 8  9 9 9  0 0 0  1 1 1  2 2 2
4 4 4  5 5 5  6 6 6  7 7 7  8 8 8  9 9 9  0 0 0  1 1 1  2 2 2  3 3 3
5 5 5  6 6 6  7 7 7  8 8 8  9 9 9  0 0 0  1 1 1  2 2 2  3 3 3  4 4 4
6 6 6  7 7 7  8 8 8  9 9 9  0 0 0  1 1 1  2 2 2  3 3 3  4 4 4  5 5 5
7 7 7  8 8 8  9 9 9  0 0 0  1 1 1  2 2 2  3 3 3  4 4 4  5 5 5  6 6 6
8 8 8  9 9 9  0 0 0  1 1 1  2 2 2  3 3 3  4 4 4  5 5 5  6 6 6  7 7 7
9 9 9  0 0 0  1 1 1  2 2 2  3 3 3  4 4 4  5 5 5  6 6 6  7 7 7  8 8 8
";
            var canvas  = PPM.Parse(ppm);
            var pattern = new UVImage(canvas);

            pattern.ColorAt(new UVPoint(0f, 0f)).Should().Be(new Color(0.9f, 0.9f, 0.9f));
            pattern.ColorAt(new UVPoint(0.3f, 0f)).Should().Be(new Color(0.2f, 0.2f, 0.2f));
            pattern.ColorAt(new UVPoint(0.6f, 0.3f)).Should().Be(new Color(0.1f, 0.1f, 0.1f));
            pattern.ColorAt(new UVPoint(1f, 1f)).Should().Be(new Color(0.9f, 0.9f, 0.9f));
        }