/// <summary> /// Recalculates the Painter. /// </summary> public override void Calc(Plot plot) { int X, Y; Plot2D plot2D = (Plot2D)plot; BitmapBuilder bmp = cache; Rectangle r = plot2D.Bounds; if (Recalc) { unsafe { lock (this) { int * pixel; Color c; bmp.Lock(); pixel = bmp.Pixel(r.X, r.Y); for (Y = r.Y; Y < r.Y + r.Height; Y++) { if (plot2D.DrawStop) { break; } for (X = r.X; X < r.X + r.Width; X++) { if (plot2D.DrawStop) { break; } try { c = F.f(plot2D.WorldCoordinateX(X), plot2D.WorldCoordinateY(Y)); } catch (ThreadAbortException ex) { throw ex; } catch (Exception e) { if (F.ThrowOnErrors) { throw e; } else { c = Color.Transparent; } } *pixel = c.ToArgb(); pixel++; } plot2D.Progress += r.Width; } bmp.Unlock(); } } Recalc = plot.DrawStop; } }
/// <summary> /// Recalculates the Painter /// </summary> public override void Calc(Plot plot) { int X, Y; double z, dzinv; Plot2D plot2D = (Plot2D)plot; Rectangle r = plot2D.Bounds; BitmapBuilder bmp; //Color c; if (Recalc) { dzinv = 1 / (Model.z1 - Model.z0); unsafe { bmp = cache; bmp.Lock(); int *pixel = bmp.Pixel(r.X, r.Y); for (Y = r.Y; Y < r.Y + r.Height; Y++) { if (plot2D.DrawStop) { break; } for (X = r.X; X < r.X + r.Width; X++) { if (plot2D.DrawStop) { break; } try { z = (F.f(plot2D.WorldCoordinateX(X), plot2D.WorldCoordinateY(Y)) - Model.z0) * dzinv; } catch (ThreadAbortException ex) { throw ex; } catch (Exception e) { if (F.ThrowOnErrors) { throw e; } else { z = double.NaN; } } if (double.IsInfinity(z) || double.IsNaN(z)) { *pixel = Color.Transparent.ToArgb(); } else { try { *pixel = F.Gradient.Color(z).ToArgb(); } catch (ThreadAbortException ex) { throw ex; } catch { *pixel = Color.Transparent.ToArgb(); } } pixel++; } plot2D.Progress += r.Width; } bmp.Unlock(); } Recalc = plot2D.DrawStop; } }