Clone() публичный Метод

public Clone ( ) : DnaDrawing
Результат DnaDrawing
Пример #1
0
        public DefaultEvolutionJob(DnaDrawing drawing, JobInfo info)
        {
            this.info = info;

            if (drawing == null)
                drawing = GetNewInitializedDrawing(info);
            lock (drawing)
            {
                currentDrawing = drawing.Clone();
            }

            currentErrorLevel = FitnessCalculator.GetDrawingFitness(currentDrawing, info.SourceImage);
        }
Пример #2
0
        private void StartEvolution()
        {
            var sourceImage = new SourceImage
                                  {
                                      Pixels = SetupSourceColorMatrix(picPattern.Image as Bitmap),
                                      Width = picPattern.Width,
                                      Height = picPattern.Height
                                  };

            var info = new JobInfo
                           {
                               Settings = Project.Settings,
                               SourceImage = sourceImage,
                           };
            //IEvolutionJob job = new LayeredEvolutionJob(sourceImage, 4);

            //DefaultEvolutionJob job = new DefaultEvolutionJob(sourceImage, currentDrawing);
            //IEvolutionJob job = new DefaultEvolutionJob(info);
            IEvolutionJob job = new ClusteredEvolutionJob(info);

            while (Project.IsRunning)
            {
                double newErrorLevel = job.GetNextErrorLevel();
                var defJob = job as DefaultEvolutionJob;
                if (defJob != null)
                    Project.Generations += defJob.Generations;

                Project.Mutations++;

                if (newErrorLevel <= Project.ErrorLevel)
                {
                    Project.Selected++;

                    if (newErrorLevel < Project.ErrorLevel)
                        Project.Positive++;
                    else
                        Project.Neutral++;

                    DnaDrawing newDrawing = job.GetDrawing();
                    if (currentDrawing == null) // to make always lockable...
                        currentDrawing = new DnaDrawing();

                    lock (currentDrawing)
                    {
                        currentDrawing = newDrawing;
                        Project.Drawing = currentDrawing.Clone();
                    }

                    Project.ErrorLevel = newErrorLevel;

                    SaveAnimationImage(newDrawing);
                }
            }
        }
Пример #3
0
        private void OpenDNA()
        {
            Stop();

            DnaDrawing drawing = Serializer.DeserializeDnaDrawing(FileUtil.GetOpenFileName(FileUtil.DnaExtension));
            if (drawing != null)
            {
                if (currentDrawing == null)
                    currentDrawing = new DnaDrawing();
                lock (currentDrawing)
                {
                    currentDrawing = drawing;
                    guiDrawing = currentDrawing.Clone();
                    Project.Drawing = currentDrawing;
                }
                ResetProjectLevels();
                RepaintCanvas();
            }
        }
Пример #4
0
        private void OpenProject()
        {
            Stop();

            string fileName = FileUtil.GetOpenFileName(FileUtil.ProjectExtension);
            DnaProject project = Serializer.DeserializeDnaProject(fileName);

            if (project != null)
            {
                Project = project;

                if (!string.IsNullOrEmpty(Project.ImagePath))
                    OpenImage(Project.ImagePath);

                if (Project.Drawing != null)
                {
                    if (currentDrawing == null)
                        currentDrawing = new DnaDrawing();

                    lock (currentDrawing)
                    {
                        currentDrawing = Project.Drawing;
                        guiDrawing = currentDrawing.Clone();
                    }
                }
                ActivateProjectSettings();

                ResetProjectLevels();
                RepaintCanvas();

                projectFileName = fileName;
            }

            SetTitleBar();
        }
Пример #5
0
        private void OpenDNA()
        {
            Stop();

            DnaDrawing drawing = Serializer.DeserializeDnaDrawing(FileUtil.GetOpenFileName(FileUtil.DnaExtension));
            if (drawing != null)
            {
                if (currentDrawing == null)
                    currentDrawing = GetNewInitializedDrawing();

                lock (currentDrawing)
                {
                    currentDrawing = drawing;
                    guiDrawing = currentDrawing.Clone();
                }
                pnlCanvas.Invalidate();
                lastRepaint = DateTime.Now;
            }
        }