public void TestAtLeastTwoUserDefinedColors() { Assert.Throws <ArgumentException>(() => { var cmap = ColorMap.CreateFromColors( new [] { new byte[] { 0, 0, 0 } }, new [] { 0.0f }, -30, 30, 78); }); }
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); } }
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(); }); } }
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); }); }
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"); }
public static void GeneratePalettes() { RainbowPalette = ColorMap.CreateFromColors(RAINBOW_PALETTE_RGB, RAINBOW_PALETTE_POSITIONS); }
public void TestWrongColorPositions() { Assert.Throws <ArgumentException>(() => { var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 0.5f, 1.2f }, -30, 30, 78); }); }
public void TestUserDefinedColorsInconsistentWithPositions() { Assert.Throws <ArgumentException>(() => { var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 1.0f }, -30, 30, 78); }); }
public void TestUserDefinedColorPositionsNotNull() { Assert.Throws <ArgumentException>(() => { var cmap = ColorMap.CreateFromColors(_colors, null, -30, 30, 78); }); }