private void draw_julia() { MyColor color = new MyColor(); Color[] cs = new Color[256]; cs = ColorMap.GetColors(13); double newRe, newIm, oldRe, oldIm, Im, step_y, step_x; Bitmap bp = new Bitmap(w, h); int i; interval_x = 3.0 / zoom; if (w >= h) { interval_y = (w / h) * interval_x; } else { interval_y = (h / w) * interval_x; } double origo_x = (interval_x / 2.0) - move_x; double origo_y = (interval_y / 2.0) - move_y; step_x = interval_x / w; step_y = interval_y / h; for (int y = 0; y < h; y++) { Im = y * step_y - origo_y; for (int x = 0; x < w; x++) { newRe = x * step_x - origo_x; newIm = Im; i = 0; while (i < maxIterations) { oldRe = newRe; oldIm = newIm; newRe = oldRe * oldRe - oldIm * oldIm + cRe; newIm = 2 * oldRe * oldIm + cIm; if ((newRe * newRe + newIm * newIm) > 2) { break; } i++; } double perc = i / ((double)(maxIterations)); int val = ((int)(perc * 255)); bp.SetPixel(x, y, cs[val]); } } var graphics = Graphics.FromImage(bp); graphics.DrawLine(Pens.Black, w / 2, 0, w / 2, h); graphics.DrawLine(Pens.Black, 0, h / 2, w, h / 2); panel.BackgroundImage = bp; }
private void draw_mandel() { Color[] cs = new Color[256]; cs = ColorMap.GetColors(5); Bitmap bp = new Bitmap(width, height); double x, y, x1, y1, xx; int looper, s, z = 0; double step_x, step_y = 0.0; step_x = (xmax - xmin) / width / zoom; step_y = (ymax - ymin) / height / zoom; x = xmin; for (s = 1; s < width; s++) { y = ymin; for (z = 1; z < height; z++) { x1 = 0; y1 = 0; looper = 0; while (looper < 100 && Math.Sqrt((x1 * x1) + (y1 * y1)) < 2) { looper++; xx = (x1 * x1) - (y1 * y1) + x; y1 = 2 * x1 * y1 + y; x1 = xx; } double perc = looper / (100.0); int val = ((int)(perc * 255)); bp.SetPixel(s, z, cs[val]); y += step_y; } x += step_x; } panel.BackgroundImage = bp; }