예제 #1
0
 public void TestAtLeastTwoUserDefinedColors()
 {
     Assert.Throws <ArgumentException>(() => {
         var cmap = ColorMap.CreateFromColors(
             new [] { new byte[] { 0, 0, 0 } }, new [] { 0.0f }, -30, 30, 78);
     });
 }
예제 #2
0
        private void CreateColorMap(Func <double, double, double> function)
        {
            var min = double.MaxValue;
            var max = double.MinValue;

            for (var x = SurfaceRect.Left; x < SurfaceRect.Right; x++)
            {
                for (var y = SurfaceRect.Top; y < SurfaceRect.Bottom; y++)
                {
                    var z = function(x, y);

                    if (z > max)
                    {
                        max = z;
                    }
                    if (z < min)
                    {
                        min = z;
                    }
                }
            }

            _colorCount = (int)_colorCountUpDown.Value;

            if (_colorMapsList.Text == "user")
            {
                _cmap = ColorMap.CreateFromColors(_colors, _positions, min, max, _colorCount);
            }
            else
            {
                _cmap = new ColorMap(_colorMapsList.Text, min, max, _colorCount);
            }
        }
예제 #3
0
        public void TestAllColorsAreRetrievedWithoutExceptionsInUserDefinedColormaps()
        {
            var cmap = ColorMap.CreateFromColors(_colors, _positions, -30, 30, 78);

            for (var i = 0; i < 78; i++)
            {
                Assert.DoesNotThrow(() => { var colors = cmap.Colors().ToList(); });
            }
        }
예제 #4
0
 public void TestIncorrectRgbFormatOfUserDefinedColors()
 {
     Assert.Throws <ArgumentException>(() => {
         var cmap = ColorMap.CreateFromColors(
             new [] {
             new byte[] { 0, 0, 0 },
             new byte[] { 0, 0 }             // error here
         },
             new [] { 0, 1.0f },
             -30, 30, 78);
     });
 }
예제 #5
0
        private void UpdatePanels()
        {
            var colors = new[]
            {
                new byte[] { 0, 0, 0 },
                new byte[] { 255, 255, 0 },
                new byte[] { 255, 0, 0 },
                new byte[] { 255, 255, 255 }
            };
            var positions = new[] { 0, 0.3f, 0.7f, 1 };

            var cmap1 = ColorMap.CreateFromColors(colors, positions, colorCount: ColorCountDefault);
            var cmap2 = new ColorMap(SelectedPalette, colorCount: ColorCountDefault);
            var cmap3 = new MirrorColorMap(cmap2);

            PaletteBrush1 = CreatePaletteBrush(cmap1);
            PaletteBrush2 = CreatePaletteBrush(cmap2);
            PaletteBrush3 = CreatePaletteBrush(cmap3);

            OnPropertyChanged("PaletteBrush1");
            OnPropertyChanged("PaletteBrush2");
            OnPropertyChanged("PaletteBrush3");
        }
예제 #6
0
 public static void GeneratePalettes()
 {
     RainbowPalette = ColorMap.CreateFromColors(RAINBOW_PALETTE_RGB, RAINBOW_PALETTE_POSITIONS);
 }
예제 #7
0
 public void TestWrongColorPositions()
 {
     Assert.Throws <ArgumentException>(() => {
         var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 0.5f, 1.2f }, -30, 30, 78);
     });
 }
예제 #8
0
 public void TestUserDefinedColorsInconsistentWithPositions()
 {
     Assert.Throws <ArgumentException>(() => {
         var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 1.0f }, -30, 30, 78);
     });
 }
예제 #9
0
 public void TestUserDefinedColorPositionsNotNull()
 {
     Assert.Throws <ArgumentException>(() => {
         var cmap = ColorMap.CreateFromColors(_colors, null, -30, 30, 78);
     });
 }