public TinyPlotter(params Func<double, double>[] functions) { var black = new Color { Red = 0, Green = 0, Blue = 0 }; foreach(var func in functions) { var curve = new Curve { Color = black, Map = func }; Curves.Add(curve); } InitializePlot(); }
void DrawCurve(Curve curve, ImageData image) { var xmin = Settings.XMin; var xmax = Settings.XMax; var ymin = Settings.YMin; var ymax = Settings.YMax; var step = Settings.DeltaX; for (double x = xmin; x <= xmax; x += step) { var y = curve.Map(x); if (y < ymin || y > ymax || double.IsNaN(y)) // off bounds or undefined continue; var point = new Point { X = x, Y = y }; var pointFromPlain = FromPointOnPlain(point, xmin, xmax, ymin, ymax, Canvas.Height, Canvas.Width); SetPixel(image, (int)pointFromPlain.X, (int)pointFromPlain.Y, curve.Color); } }