public static void Mutate(this DnaBrush dnaBrush, DnaDrawing dnaDrawing)
        {
            if (Tools.WillMutate(Settings.ActiveRedMutationRate))
            {
                dnaBrush.Red = Tools.GetRandomNumber(Settings.ActiveRedRangeMin, Settings.ActiveRedRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveGreenMutationRate))
            {
                dnaBrush.Green = Tools.GetRandomNumber(Settings.ActiveGreenRangeMin, Settings.ActiveGreenRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveBlueMutationRate))
            {
                dnaBrush.Blue = Tools.GetRandomNumber(Settings.ActiveBlueRangeMin, Settings.ActiveBlueRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveAlphaMutationRate))
            {
                dnaBrush.Alpha = Tools.GetRandomNumber(Settings.ActiveAlphaRangeMin, Settings.ActiveAlphaRangeMax);
                dnaDrawing.SetDirty();
            }
        }
Пример #2
0
        public static void Mutate(this DnaDrawing dnaDrawing)
        {
            if (Tools.WillMutate(Settings.ActiveAddPolygonMutationRate))
            {
                if (dnaDrawing.AddPolygon())
                {
                    dnaDrawing.SetDirty();
                }
            }

            if (Tools.WillMutate(Settings.ActiveRemovePolygonMutationRate))
            {
                if (dnaDrawing.RemovePolygon())
                {
                    dnaDrawing.SetDirty();
                }
            }

            if (Tools.WillMutate(Settings.ActiveMovePolygonMutationRate))
            {
                if (dnaDrawing.MovePolygon())
                {
                    dnaDrawing.SetDirty();
                }
            }

            foreach (DnaPolygon polygon in dnaDrawing.Polygons)
            {
                polygon.Mutate(dnaDrawing);
            }
        }
Пример #3
0
        public static void Mutate(this DnaBrush dnaBrush, DnaDrawing dnaDrawing)
        {
            if (Tools.WillMutate(Settings.ActiveRedMutationRate))
            {
                dnaBrush.Red = Tools.GetRandomNumber(Settings.ActiveRedRangeMin, Settings.ActiveRedRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveGreenMutationRate))
            {
                dnaBrush.Green = Tools.GetRandomNumber(Settings.ActiveGreenRangeMin, Settings.ActiveGreenRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveBlueMutationRate))
            {
                dnaBrush.Blue = Tools.GetRandomNumber(Settings.ActiveBlueRangeMin, Settings.ActiveBlueRangeMax);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveAlphaMutationRate))
            {
                dnaBrush.Alpha = Tools.GetRandomNumber(Settings.ActiveAlphaRangeMin, Settings.ActiveAlphaRangeMax);
                dnaDrawing.SetDirty();
            }
        }
        public static void Mutate(this DnaPoint dnaPoint, DnaDrawing dnaDrawing)
        {
            if (Tools.WillMutate(Settings.ActiveMovePointMaxMutationRate))
            {
                dnaPoint.X = Tools.GetRandomNumber(0, dnaDrawing.Width);
                dnaPoint.Y = Tools.GetRandomNumber(0, dnaDrawing.Height);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveMovePointMidMutationRate))
            {
                dnaPoint.X =
                    MathUtils.Clamp(
                        dnaPoint.X +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMid, Settings.ActiveMovePointRangeMid), 0,
                        dnaDrawing.Width);

                dnaPoint.Y =
                    MathUtils.Clamp(
                        dnaPoint.Y +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMid, Settings.ActiveMovePointRangeMid), 0,
                        dnaDrawing.Height);

                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveMovePointMinMutationRate))
            {
                dnaPoint.X =
                    MathUtils.Clamp(
                        dnaPoint.X +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMin, Settings.ActiveMovePointRangeMin), 0,
                        dnaDrawing.Width);

                dnaPoint.Y =
                    MathUtils.Clamp(
                        dnaPoint.Y +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMin, Settings.ActiveMovePointRangeMin), 0,
                        dnaDrawing.Height);

                dnaDrawing.SetDirty();
            }
        }
Пример #5
0
        public static void Mutate(this DnaPoint dnaPoint, DnaDrawing dnaDrawing)
        {
            if (Tools.WillMutate(Settings.ActiveMovePointMaxMutationRate))
            {
                dnaPoint.X = Tools.GetRandomNumber(0, dnaDrawing.Width);
                dnaPoint.Y = Tools.GetRandomNumber(0, dnaDrawing.Height);
                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveMovePointMidMutationRate))
            {
                dnaPoint.X =
                    MathUtils.Clamp(
                        dnaPoint.X +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMid, Settings.ActiveMovePointRangeMid), 0,
                        dnaDrawing.Width);

                dnaPoint.Y =
                    MathUtils.Clamp(
                        dnaPoint.Y +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMid, Settings.ActiveMovePointRangeMid), 0,
                        dnaDrawing.Height);

                dnaDrawing.SetDirty();
            }

            if (Tools.WillMutate(Settings.ActiveMovePointMinMutationRate))
            {
                dnaPoint.X =
                    MathUtils.Clamp(
                        dnaPoint.X +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMin, Settings.ActiveMovePointRangeMin), 0,
                        dnaDrawing.Width);

                dnaPoint.Y =
                    MathUtils.Clamp(
                        dnaPoint.Y +
                        Tools.GetRandomNumber(-Settings.ActiveMovePointRangeMin, Settings.ActiveMovePointRangeMin), 0,
                        dnaDrawing.Height);

                dnaDrawing.SetDirty();
            }
        }
Пример #6
0
        public static void Mutate(this DnaPolygon dnaPolygon, DnaDrawing drawing)
        {
            if (Tools.WillMutate(Settings.ActiveAddPointMutationRate))
            {
                if (dnaPolygon.AddPoint(drawing))
                {
                    drawing.SetDirty();
                }
            }

            if (Tools.WillMutate(Settings.ActiveRemovePointMutationRate))
            {
                if (dnaPolygon.RemovePoint(drawing))
                {
                    drawing.SetDirty();
                }
            }

            dnaPolygon.Brush.Mutate(drawing);
            dnaPolygon.Points.ForEach(p => p.Mutate(drawing));
        }
        public static void Mutate(this DnaPolygon dnaPolygon, DnaDrawing drawing)
        {
            if (Tools.WillMutate(Settings.ActiveAddPointMutationRate))
            {
                if (dnaPolygon.AddPoint(drawing))
                {
                    drawing.SetDirty();
                }
            }

            if (Tools.WillMutate(Settings.ActiveRemovePointMutationRate))
            {
                if (dnaPolygon.RemovePoint(drawing))
                {
                    drawing.SetDirty();
                }
            }

            dnaPolygon.Brush.Mutate(drawing);
            dnaPolygon.Points.ForEach(p => p.Mutate(drawing));
        }
Пример #8
0
        public double mutateScalar(double scalar, double min,  double max, DnaDrawing drawing)
        {
            if (tool.WillMutate(Settings.ActiveCircleSizeMidMutationRate))
            {
                drawing.SetDirty();
                return Math.Min(Math.Max(min, scalar +
                                    tool.GetRandomNumber(-Settings.ActiveCircleSizeRangeMid,
                                                           Settings.ActiveCircleSizeRangeMid)), max);
            }

            if (tool.WillMutate(Settings.ActiveCircleSizeMinMutationRate))
            {
                drawing.SetDirty();
                return Math.Min(Math.Max(min, scalar +
                                 tool.GetRandomNumber(-Settings.ActiveCircleSizeRangeMin,
                                                       Settings.ActiveCircleSizeRangeMin)), max);
            }

            return scalar;
        }
Пример #9
0
        public void MutateOrigin(DnaDrawing drawing)
        {
            if (tool.WillMutate(Settings.ActiveMovePointMaxMutationRate))
            {
                origin.X = tool.GetRandomNumber(-Settings.ActiveMaxCircleRadius, Tools.MaxWidth + Settings.ActiveMaxCircleRadius);
                origin.Y = tool.GetRandomNumber(-Settings.ActiveMaxCircleRadius, Tools.MaxHeight + Settings.ActiveMaxCircleRadius);
                drawing.SetDirty();
            }

            if (tool.WillMutate(Settings.ActiveMovePointMidMutationRate))
            {
                origin.X =
                    Math.Min(
                        Math.Max(-Settings.ActiveMaxCircleRadius,
                                 origin.X +
                                 tool.GetRandomNumber(-Settings.ActiveMovePointRangeMid,
                                                       Settings.ActiveMovePointRangeMid)), Tools.MaxWidth + Settings.ActiveMaxCircleRadius);
                origin.Y =
                    Math.Min(
                        Math.Max(-Settings.ActiveMaxCircleRadius,
                                 origin.Y +
                                 tool.GetRandomNumber(-Settings.ActiveMovePointRangeMid,
                                                       Settings.ActiveMovePointRangeMid)), Tools.MaxHeight + Settings.ActiveMaxCircleRadius);
                drawing.SetDirty();
            }

            if (tool.WillMutate(Settings.ActiveMovePointMinMutationRate))
            {
                origin.X =
                    Math.Min(
                        Math.Max(-Settings.ActiveMaxCircleRadius,
                                 origin.X +
                                 tool.GetRandomNumber(-Settings.ActiveMovePointRangeMin,
                                                       Settings.ActiveMovePointRangeMin)), Tools.MaxWidth + Settings.ActiveMaxCircleRadius);
                origin.Y =
                    Math.Min(
                        Math.Max(-Settings.ActiveMaxCircleRadius,
                                 origin.Y +
                                 tool.GetRandomNumber(-Settings.ActiveMovePointRangeMin,
                                                       Settings.ActiveMovePointRangeMin)), Tools.MaxHeight + Settings.ActiveMaxCircleRadius);
                drawing.SetDirty();
            }
        }
Пример #10
0
        private void RemovePoint(DnaDrawing drawing)
        {
            if (Points.Count > Settings.ActivePointsPerPolygonMin)
            {
                int index = tool.GetRandomNumber(0, Points.Count);
                Points.RemoveAt(index);

                drawing.SetDirty();
            }
        }
Пример #11
0
        private void AddPoint(DnaDrawing drawing)
        {
            if (Points.Count < Settings.ActivePointsPerPolygonMax)
            {
                var newPoint = new DnaPoint();

                int index = tool.GetRandomNumber(1, Points.Count - 1);

                DnaPoint prev = Points[index - 1];
                DnaPoint next = Points[index];

                newPoint.X = (prev.X + next.X)/2;
                newPoint.Y = (prev.Y + next.Y)/2;

                Points.Insert(index, newPoint);

                drawing.SetDirty();
            }
        }