Beispiel #1
0
        private void DrawJulia()
        {
            int       width  = pictureBox.Width;
            int       height = pictureBox.Height;
            double    step   = 0.002;        // TODO:
            ImgRegion region = new ImgRegion // TODO:
            {
                Step  = step,
                Left  = -width * step / 2,
                Right = width * step / 2,
                Down  = -height * step / 2,
                Up    = height * step / 2,
            };

            double[] bg_rgb = new double[3] {
                0.5, 1.5, 1.5
            };                                                 // TODO:
            double[] fg_rgb = new double[3] {
                0.7, 0.8, 0.9
            };                                                                  // TODO:
            Double2IntColor d2i  = (v, coef) => (int)(Math.Pow(v, coef) * 255); // TODO:
            ColorMap        cmap = ColorMaps.GetCmap(bg_rgb, fg_rgb, d2i);

            double  speedRate = 0.2; // TODO:
            double  randRate  = 0.5; // TODO:
            Complex mouseC    = new Complex(mouseX * step + region.Left, region.Up - mouseY * step);
            Complex randC     = new Complex(rnd.NextDouble() - 0.5, rnd.NextDouble() - 0.5);

            c += speedRate * (mouseC - c) + randRate * randC;
            pictureBox.Image = Julia.GetJulia(region, c, cmap);
        }
Beispiel #2
0
        public static ColorMap GetCmap(double[] bg_rgb, double[] fg_rgb, Double2IntColor d2i)
        {
            return((norm, iter) =>
            {
                if (norm < Julia.R)
                {
                    return Color.Black;
                }

                double v = Math.Log(iter - Math.Log(Math.Log(norm, 2), 2) + 2, 2) / 4;
                int r, g, b;
                if (v < 1.0)
                {
                    double conv = Math.Max(0, v); // 收敛率
                    r = d2i(conv, bg_rgb[0]);
                    g = d2i(conv, bg_rgb[1]);
                    b = d2i(conv, bg_rgb[2]);
                }
                else
                {
                    double div = Math.Max(0, 2 - v);
                    r = d2i(div, fg_rgb[0]); // 发散率
                    g = d2i(div, fg_rgb[1]);
                    b = d2i(div, fg_rgb[2]);
                }
                return Color.FromArgb(r, g, b);
            });
        }