private void CalcDiagram()
        {
            gifCreater.images.Clear();

            int startIter = maxGIFIterations - 1;

            if (diagramDrawer.CreateGif)
            {
                startIter = 1;
            }

            int s = 2;
            int d = MaxFunctionIterations / maxGIFIterations;

            if (maxGIFIterations > 2)
            {
                d = MaxFunctionIterations / (maxGIFIterations - 2);
            }

            for (int m = startIter; m < maxGIFIterations; m++)
            {
                decimal start = DiagramStartParameter;
                decimal stop  = DiagramStopParameter;
                if (DiagramStartParameter > DiagramStopParameter)
                {
                    start = DiagramStopParameter;
                    stop  = DiagramStartParameter;
                }
                int     tempMax = CurrentFunction.MaxIterations;
                decimal tempP   = CurrentFunction.Parameter;
                decimal delta   = 1.0M * (stop - start) / BSize;
                diagramPoints.Clear();
                try {
                    for (int i = 0; i < BSize; i++)
                    {
                        report.PercentageComplete = i;
                        if (progressHandler is IProgress <ProgressReportModel> progress)
                        {
                            progress.Report(report);
                        }
                        if (token.IsCancellationRequested)
                        {
                            break;
                        }

                        decimal      p = start + i * delta;
                        BaseFunction diagramFunction = CurrentFunction;
                        diagramFunction.Parameter = p;
                        if (diagramDrawer.CreateGif)
                        {
                            diagramFunction.MaxIterations = s;
                        }
                        else
                        {
                            diagramFunction.MaxIterations = MaxFunctionIterations;
                        }
                        diagramFunction.SetFurcationPoints();
                        if (diagramFunction.furcationPoints.Count > 0)
                        {
                            if (CurrentFunction is HenonFunction)
                            {
                                for (int dp = diagramFunction.furcationPoints.Count - 1; dp > diagramFunction.furcationPoints.Count - 250 && dp >= 0; dp--)
                                {
                                    DiagramSet ds = diagramFunction.furcationPoints[dp];
                                    diagramPoints.Add(new DiagramSet(i, ds));
                                }
                            }
                            else
                            {
                                int last = diagramFunction.furcationPoints.Count - 1;
                                diagramPoints.Add(new DiagramSet(i, diagramFunction.furcationPoints[last]));
                            }
                        }
                        else
                        {
                            diagramPoints.Add(new DiagramSet(i, 2));
                        }
                    }
                    CurrentFunction.MaxIterations = tempMax;
                    CurrentFunction.Parameter     = tempP;
                    PlotDiagram();
                    if (diagramDrawer.CreateGif)
                    {
                        gifCreater.images.Add(diagramDrawer.Copy4GIF);
                        Thread.Sleep(1);
                    }
                    PlotForm.SetCurrentIteration(m);
                    if (s < 100)
                    {
                        s += 10;
                    }
                    else
                    if (s < 1000)
                    {
                        s += 100;
                    }
                    else
                    {
                        s += d;
                    }
                }
                catch {}
            }
            int mSec = 40 / maxGIFIterations;

            if (mSec == 0)
            {
                mSec = 1;
            }
            if (diagramDrawer.CreateGif)
            {
                gifCreater.Create(mSec, DiagramGifFileName);
            }
            ParamChoice2Form(DiagramStopParameter);
            diagramDrawer.CreateGif = false;
        }