public ComponTransformViewModel() { _transformModel = new TransformModel(); _flameColorMode = FlameColorMode.Color; Command = new RelayCommand(CommandHandler); GradientModel = new GradientModel(Colors.Gray, Colors.Gray); ColorPosition = .5; FColor = Colors.Gray; Parameter1Visibility = Visibility.Collapsed; Parameter2Visibility = Visibility.Collapsed; Parameter3Visibility = Visibility.Collapsed; Parameter4Visibility = Visibility.Collapsed; Variations = VariationFactoryModel.StaticVariationFactory.VariationNames; VariationSelected = "Linear"; BindStorage.SetActionFor(ActionValueChanged, _propParameters); BindStorage.SetActionFor(ActionValueChanged, _propValues2); BindStorage.SetActionFor(ActionTransformValueChanged, _propValues); BindStorage.SetActionFor(ActionVariationChanged, _propVariation); SetCoefficients(); }
private void ActionCallback(Color color) { if (_selectedColorId >= 0) { var e = _ellipses[_selectedColorId]; e.Fill = new SolidColorBrush(color); switch (_colorMode) { case 2: GradientModel.Add(_selectedColorId, color, _newPosition); break; case 1: GradientModel.ChangeColor(_selectedColorId, color); break; } } else { switch (_selectedColorId) { case -11: ColorLeft = new SolidColorBrush(color); break; case -22: ColorRight = new SolidColorBrush(color); break; } } RedrawGradient(); }
private void ColorPickProviderCallback(ProviderCallbackType providerCallbackType, string message) { switch (providerCallbackType) { case ProviderCallbackType.ShowControl: ShowControl = _colorPickProvider.ShowControl; _providerCallback.Invoke(ProviderCallbackType.ShowControl, string.Empty); break; case ProviderCallbackType.End: if (_colorPickProvider.Result) { var color = _colorPickProvider.ResultColor; _gradientModel = GetGradientModel(_gradientPickView); _gradientModel.ChangeColor(_gradientId, color); } _gradientPickView = new GradientPickView(_gradientModel, GradientPickCallback); ShowControl = _gradientPickView; _providerCallback.Invoke(ProviderCallbackType.ShowControl, string.Empty); break; default: throw new ArgumentOutOfRangeException(nameof(providerCallbackType), providerCallbackType, null); } }
/// <summary> /// Supports concentration gradients. /// </summary> /// <param name="DropletPrintStyleModel"></param> public DropletModel(DropletPrintStyleModel DropletPrintStyleModel) { _interpolateDistance = DropletPrintStyleModel.InterpolateDistance; _gradientShape = DropletPrintStyleModel.GradientShape; _gradientScaling = DropletPrintStyleModel.GradientScaling; Point3D point1 = new Point3D(DropletPrintStyleModel.X1, DropletPrintStyleModel.Y1, DropletPrintStyleModel.Z1); Point3D point2 = new Point3D(DropletPrintStyleModel.X2, DropletPrintStyleModel.Y2, DropletPrintStyleModel.Z2); Point3D point3 = new Point3D(DropletPrintStyleModel.X3, DropletPrintStyleModel.Y3, DropletPrintStyleModel.Z3); switch (DropletPrintStyleModel.GradientShape) { case GradientShape.None: _gradientModel = null; break; case GradientShape.Point: _gradientModel = new PointModel(_gradientScaling, DropletPrintStyleModel.PercentPerMm, point1); break; case GradientShape.Line: _gradientModel = new LineModel(_gradientScaling, DropletPrintStyleModel.PercentPerMm, point1, point2); break; case GradientShape.Plane: _gradientModel = new PlaneModel(_gradientScaling, DropletPrintStyleModel.PercentPerMm, point1, point2, point3); break; } }
public GradientPickProvider(Action <ProviderCallbackType, string> providerCallback, GradientModel gradientModel, double gradientValue) { _providerCallback = providerCallback; _gradientModel = gradientModel.Copy(); _gradientPickView = new GradientPickView(_gradientModel, gradientValue, GradientPickCallback); GradientMode = GradientMode.Select; }
public GradientPickProvider(Action <ProviderCallbackType, string> providerCallback, GradientModel gradientModel) { _providerCallback = providerCallback; _gradientModel = gradientModel.Copy(); _gradientPickView = new GradientPickView(_gradientModel, GradientPickCallback); GradientMode = GradientMode.Edit; }
public ActionResult Index(string startColor, string endColor, int numColors) { GradientModel myModel = new GradientModel(startColor, endColor, numColors); ViewBag.myGradient = myModel.getGradient(); foreach (Color x in myModel.getGradient()) { System.Diagnostics.Debug.WriteLine("end color::: " + x); } return(View(myModel)); }
private async void InitGradientSelect(double position) { await Task.Run(() => { while (_canvasMiddle == null || _canvasMiddleScanner == null) { Thread.Sleep(10); } }); CreateEllipse(GiveIdModel.Get, GradientModel.GetFromPosition(position), position); }
private static void GetGradientModel(FlameModel flameModel, out GradientModel gradientModel, out double[] gradientValues) { gradientModel = null; gradientValues = null; if (flameModel?.GradientPack == null) { return; } var gm = new GradientModel(flameModel.GradientPack); gradientModel = gm.Copy(); gradientValues = flameModel.FunctionColorPositions.ToArray(); }
public GradientPickViewModel(GradientModel gradientModel, double position, Action <GradientCallbackType, object, double> gradientPickCallback) { _callbackPickGradient = gradientPickCallback; _stopwatch.Start(); _halfWidth = EllipseWidth * .5; _gap = (20.0 - EllipseWidth) * .5; GradientModel = gradientModel.Copy(); GradientMode = GradientMode.Select; InitCommands(); InitGradientSelect(position); RedrawGradient(); }
public GradientPickViewModel() { Id = GiveIdModel.Get; _stopwatch.Start(); _halfWidth = EllipseWidth * .5; _gap = (20.0 - EllipseWidth) * .5; GradientModel = new GradientModel(Colors.Gray, Colors.Gray); InitCommands(); ColorLeft = new SolidColorBrush(Colors.CadetBlue); ColorRight = new SolidColorBrush(Colors.Blue); RedrawGradient(); }
public GradientPickViewModel(GradientModel gradientModel, Action <GradientCallbackType, object, double> gradientPickCallback) { _callbackPickGradient = gradientPickCallback; _stopwatch.Start(); _halfWidth = EllipseWidth * .5; _gap = (20.0 - EllipseWidth) * .5; GradientModel = gradientModel.Copy(); GradientMode = GradientMode.Edit; InitCommands(); InitGradientEdit(); ThicknessSquares = new Thickness(1); RedrawGradient(); }
public MainViewModel() { CM1 = new ColorModel(); CM2 = new ColorModel(); GM = new GradientModel(); Binding b1 = new Binding("Color"); b1.Source = CM1; b1.Mode = BindingMode.OneWay; BindingOperations.SetBinding(GM, GradientModel.FirstProperty, b1); Binding b2 = new Binding("Color"); b2.Source = CM2; b2.Mode = BindingMode.OneWay; BindingOperations.SetBinding(GM, GradientModel.LastProperty, b2); }
public GradientPickerViewModel(GradientModel gradientModel, double position, string callbackString1 = "", string callbackString2 = "") { if (!string.IsNullOrWhiteSpace(callbackString1)) { _callbackString1 = callbackString1; } if (!string.IsNullOrWhiteSpace(callbackString2)) { _callbackString2 = callbackString2; } _stopwatch.Start(); _halfWidth = EllipseWidth * .5; _gap = (20.0 - EllipseWidth) * .5; GradientModel = gradientModel; GradientMode = GradientMode.Select; InitCommands(); InitGradientSelect(position); RedrawGradient(); }
public GradientPickerViewModel(GradientModel gradientModel, string callbackString1 = "", string callbackString2 = "") { if (!string.IsNullOrWhiteSpace(callbackString1)) { _callbackString1 = callbackString1; } if (!string.IsNullOrWhiteSpace(callbackString2)) { _callbackString2 = callbackString2; } _stopwatch.Start(); _halfWidth = EllipseWidth * .5; _gap = (20.0 - EllipseWidth) * .5; GradientModel = gradientModel; GradientMode = GradientMode.Edit; InitCommands(); InitGradientEdit(); ThicknessSquares = new Thickness(1); RedrawGradient(); }
private Hsb GetColorModeGradient(uint x, uint y, IReadOnlyList <double> gradientValues, GradientModel gradModel) { var length = gradientValues.Count; var total = 0u; var sum = 0.0; for (var i = 0; i < length; i++) { var d = _display[x, y, i]; sum += d * gradientValues[i]; total += d; } if (total == 0) { return(new Hsb()); } var colorValue = sum / total; return(gradModel.GetLabFromPosition(colorValue).To <Hsb>()); }
public RenderPackModel(TransformModel[] transformations, VariationModel[] variations, ViewSettingsModel viewSettings, RenderSettingsModel renderSettings, FlameColorMode colorMode, GradientModel gradModel) { Transformations = transformations; Variations = variations; ViewSettings = viewSettings; RenderSettings = renderSettings; ColorMode = colorMode; if (gradModel != null) { GradModelCopy = gradModel.Copy(); } }
public GradientPickerView(GradientModel gradientModel, string callbackString1 = "", string callbackString2 = "") { InitializeComponent(); DataContext = new GradientPickerViewModel(gradientModel, callbackString1, callbackString2); }
public BitmapSource GetBitmapForRender(double[] gradientValues, GradientModel gradModel, bool fast = false) { var rect = new Int32Rect(0, 0, Width, Height); var img = new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr32, null); Algebra.DividePlane(Width, Height, Environment.ProcessorCount, out var dic); var length = dic.Count; // var labsCm = ColorsToLabsCm(funColors); var stride = Width * 4; var a = new byte[stride * Height]; _gm = gradModel.Copy(); Parallel.For(0, length, i => { var d = dic[i]; // var iLabCm = labsCm.ToArray(); var f = fast; // var contrast = Contrast; var str = stride; for (var y = (uint)d[1]; y < d[1] + d[3]; y++) { for (var x = (uint)d[0]; x < d[0] + d[2]; x++) { var shots = CountShots(x, y); long n; if (shots == 0) { n = y * str + x * 4; a[n] = BackColor.B; a[n + 1] = BackColor.G; a[n + 2] = BackColor.R; a[n + 3] = 255; continue; } var colorHsb = GetColorModeGradient(x, y, gradientValues, _gm); var colorCm = colorHsb.ToRgb(); var cCmRgb = Color.FromRgb((byte)colorCm.R, (byte)colorCm.G, (byte)colorCm.B); var log = 1.0; if (!f) { log = Math.Log(1.0 + shots, Max); } // log = Math.Log(shots)/shots;//grad cCmRgb = Blend(cCmRgb, BackColor, log); var r = cCmRgb.R; var g = cCmRgb.G; var b = cCmRgb.B; // // var colorHsb = colorGm.To<Hsb>(); // if (!f) // { // // var log = Math.Log(1.0 + shots, Max) * contrast; // // colorGm.L = log; // var colorB = colorHsb.B; // colorB = Algebra.Map(Math.Log(1.0 + shots, Max), 0.0, 1.0, 0.0, colorB); // // colorHsb.B = Math.Log(1.0 + shots, Max); // colorHsb.B = colorB; // } // // // var cCmRgb = colorGm.ToRgb(); // var cCmRgb = colorHsb.ToRgb(); // var r = (byte) Math.Round(cCmRgb.R); // var g = (byte) Math.Round(cCmRgb.G); // var b = (byte) Math.Round(cCmRgb.B); n = y * str + x * 4; a[n] = b; a[n + 1] = g; a[n + 2] = r; a[n + 3] = 255; } } }); img.Lock(); img.WritePixels(rect, a, stride, 0); img.Unlock(); img.Freeze(); return(img); }
public GradientPickView(GradientModel gradientModel, double gradientValue, Action <GradientCallbackType, object, double> gradientPickCallback) { InitializeComponent(); DataContext = new GradientPickViewModel(gradientModel, gradientValue, gradientPickCallback); }
public static BitmapSource GetImage(Color[] colors, double[] gradientValues, GradientModel gradientModel) { return(gradientModel == null ? Display.GetBitmapForRender(colors) : Display.GetBitmapForRender(gradientValues, gradientModel)); }
/// <summary> /// A shortcut to apply gradient model for each of the breaks of the colors scheme. /// </summary> /// <param name="GradientModel">New gradient model.</param> /// \new491 Added in version 4.9.1 public void ApplyGradientModel(GradientModel GradientModel) { throw new NotImplementedException(); }
private static RenderSequenceModel PrepareRsm(RenderPackModel renderPack, RenderActionsModel renderActionsPack, int renderId, bool draftMode = true, bool continueRender = false) { var cores = Environment.ProcessorCount; var symmetry = renderPack.ViewSettings.Symmetry; var totalPointsPerIteration = renderPack.RenderSettings.ShotsPerIteration; var imageSize = new Size(renderPack.ViewSettings.ImageWidth, renderPack.ViewSettings.ImageHeight); var renderColorMode = renderPack.RenderSettings.RenderColorMode; var translationMatrix = Matrix.FromViewSettings(renderPack.ViewSettings); var colorCount = renderPack.Transformations.Length; var iterators = new IteratorModel[cores]; for (var i = 0; i < cores; i++) { iterators[i] = new IteratorModel(renderPack); } var sector = Math.PI * 2.0 / symmetry; LogDisplayModel display; if (continueRender && HasRender) { display = Display; } else { display = new LogDisplayModel((int)imageSize.Width, (int)imageSize.Height, renderPack.Transformations.Length, renderPack.ViewSettings.BackColor); } display.RenderColorMode = renderColorMode; _transformationColors = new Color[colorCount]; _transformationGradientValues = new double[colorCount]; for (var i = 0; i < colorCount; i++) { _transformationColors[i] = renderPack.Transformations[i].Color; } for (var i = 0; i < colorCount; i++) { _transformationGradientValues[i] = renderPack.Transformations[i].ColorPosition; } _gradModel = renderPack.GradModelCopy; var rsm = new RenderSequenceModel { TotalIterations = renderPack.RenderSettings.Iterations, Cores = cores, Iterators = iterators, TotalPointsPerCore = totalPointsPerIteration / cores / symmetry, Symmetry = symmetry, TranslationArray = translationMatrix.Array, CenterPoint = new Point(renderPack.ViewSettings.HalfWidth, renderPack.ViewSettings.HalfHeight), ImageSize = imageSize, Display = display, RenderActionsPack = renderActionsPack, RenderId = renderId, DraftMode = draftMode, RenderPack = renderPack, IsDrawingIntermediate = false, SectorCos = Math.Cos(sector), SectorSin = Math.Sin(sector) }; return(rsm); }