private void mandelbrotClick(object sender, System.EventArgs e) { Function2D m = new Function2D(); //The source represents the body of the following function: //double[] p, dfdp; //double f(double x, double y) { // ... //} m.source = "double xn = 0, yn = 0, x2 = 0, y2 = 0;" + "for (int n = 0; n < 500; n++) {" + " yn = 2*xn*yn + y;" + " xn = x2 - y2 + x;" + " x2 = xn*xn; y2 = yn*yn;" + " if (x2 + y2 > 4) return n;" + "} return 0;"; m.Compile(true); graph.SetRange(graph.x0, graph.x1, graph.y0, graph.y1, 0, 20); graph.Model.Items.Add(m); graph.Invalidate(); }
/// <summary> /// This method is called to print an individual page. /// </summary> protected override void OnPrintPage(System.Drawing.Printing.PrintPageEventArgs e) { GraphControl printControl = new GraphControl(); Rectangle b = e.MarginBounds, clip; Graphics g = e.Graphics; g.TranslateTransform(b.X, b.Y, MatrixOrder.Append); clip = new Rectangle(0, 0, b.Width, b.Height); g.SetClip(clip); printControl.Bounds = b; printControl.SetRange(printControl.x0, printControl.x1, printControl.y0, printControl.y1); printControl.Model = model; printControl.AsyncDraw = false; g.SmoothingMode = SmoothingMode.HighQuality; printControl.PaintGraph(g); printControl.Dispose(); }