Beispiel #1
0
        internal void Mutate(DnaDrawing drawing, JobInfo info)
        {
            if (info.WillMutate(info.Settings.ColorMutationRate))
            {
                Red = info.GetRandomNumber(0, 255);

                drawing.SetDirty();
            }

            if (info.WillMutate(info.Settings.ColorMutationRate))
            {
                Green = info.GetRandomNumber(0, 255);

                drawing.SetDirty();
            }
            if (info.WillMutate(info.Settings.ColorMutationRate))
            {
                Blue = info.GetRandomNumber(0, 255);

                drawing.SetDirty();
            }

            if (info.WillMutate(info.Settings.ColorMutationRate))
            {
                Alpha = info.GetRandomNumber(info.Settings.AlphaRangeMin, info.Settings.AlphaRangeMax);

                drawing.SetDirty();
            }
        }
Beispiel #2
0
        internal void Init(DnaDrawing drawing, JobInfo info)
        {
            Points = new List<DnaPoint>();

            //int count = info.GetRandomNumber(3, 3);
            var origin = new DnaPoint();
            origin.Init(drawing, info);

            if (drawing.Polygons.Count < 1)
            {
                origin.X = info.SourceImage.Width / 2;
                origin.Y = info.SourceImage.Height / 2;
            }

            for (int i = 0; i < info.Settings.PointsPerPolygonMin; i++)
            {
                var point = new DnaPoint
                                {
                                    X =
                                        Math.Min(Math.Max(0, origin.X + info.GetRandomNumber(-3, 3)),
                                                 info.SourceImage.Width),
                                    Y =
                                        Math.Min(Math.Max(0, origin.Y + info.GetRandomNumber(-3, 3)),
                                                 info.SourceImage.Height)
                                };

                Points.Add(point);
            }

            Brush = new DnaBrush();
            Brush.Init(info);
        }
Beispiel #3
0
 internal void Init(JobInfo info)
 {
     Red = info.GetRandomNumber(0, 255);
     Green = info.GetRandomNumber(0, 255);
     Blue = info.GetRandomNumber(0, 255);
     Alpha = info.GetRandomNumber(10, 60);
 }
Beispiel #4
0
        internal void Mutate(DnaDrawing drawing, JobInfo info)
        {
            if (!info.Settings.MuteMovePointMax)
            {
                if (info.WillMutate(info.Settings.MovePointMaxMutationRate))
                {
                    X = info.GetRandomNumber(0, info.SourceImage.Width);
                    Y = info.GetRandomNumber(0, info.SourceImage.Height);
                    drawing.SetDirty();
                }
            }

            if (!info.Settings.MuteMovePointMid)
            {
                if (info.WillMutate(info.Settings.MovePointMidMutationRate))
                {

                    X = X
                        .Randomize(info ,- info.Settings.MovePointRangeMid, info.Settings.MovePointRangeMid)
                        .Max(0)
                        .Min(info.SourceImage.Width);

                    Y = Y
                        .Randomize(info, -info.Settings.MovePointRangeMid, info.Settings.MovePointRangeMid)
                        .Max(0)
                        .Min(info.SourceImage.Height);

                    drawing.SetDirty();
                }
            }

            if (!info.Settings.MuteMovePointMin)
            {
                if (info.WillMutate(info.Settings.MovePointMinMutationRate))
                {
                    X = X
                        .Randomize(info, -info.Settings.MovePointRangeMin, info.Settings.MovePointRangeMin)
                        .Max(0)
                        .Min(info.SourceImage.Width);

                    Y = Y
                        .Randomize(info, -info.Settings.MovePointRangeMin, info.Settings.MovePointRangeMin)
                        .Max(0)
                        .Min(info.SourceImage.Height);

                    drawing.SetDirty();
                }
           }
        }
Beispiel #5
0
        public void Init(DnaDrawing drawing, JobInfo info)
        {
            Points = new List<DnaPoint>();

            //int count = info.GetRandomNumber(3, 3);
            var origin = new DnaPoint();
            origin.Init(drawing, info);

            if (drawing.Polygons.Count < 1)
            {
                origin.X = info.SourceImage.Width / 2;
                origin.Y = info.SourceImage.Height / 2;
            }

            for (int i = 0; i < info.Settings.PointsPerPolygonMin; i++)
            {
                var point = new DnaPoint
                                {
                                    X =
                                        Math.Min(Math.Max(0, origin.X + info.GetRandomNumber(-3, 3)),
                                                 info.SourceImage.Width),
                                    Y =
                                        Math.Min(Math.Max(0, origin.Y + info.GetRandomNumber(-3, 3)),
                                                 info.SourceImage.Height)
                                };

                Points.Add(point);
            }

            bool findNew = true;

            if (info.Settings.MuteCurvePolygon &&
                info.Settings.MuteLinePolygon &&
                info.Settings.MuteCurveFillPolygon &&
                info.Settings.MuteLineFillPolygon)
                findNew = false;

            Width = info.GetRandomNumber(1, 8);

            while (findNew)
            {
                bool splines = (info.GetRandomNumber(0, 2) == 1) ? true : false;
                bool filled = (info.GetRandomNumber(0, 2) == 1) ? true : false;
                findNew = !SetSplinesAndFilled(info.Settings, splines, filled);
            }

            Brush = new DnaBrush();
            Brush.Init(info);
        }
Beispiel #6
0
 internal static int Randomize(this int self,JobInfo info, int min, int max)
 {
     return self + info.GetRandomNumber(min, max);
 }
Beispiel #7
0
 internal void Init(DnaDrawing drawing,JobInfo info)
 {
     X = info.GetRandomNumber(0, info.SourceImage.Width);
     Y = info.GetRandomNumber(0, info.SourceImage.Height);
 }
Beispiel #8
0
 public void RemovePolygon(JobInfo info)
 {
     if (Polygons.Count > info.Settings.PolygonsMin)
     {
         int index = info.GetRandomNumber(0, Polygons.Count);
         Polygons.RemoveAt(index);
         SetDirty();
     }
 }
Beispiel #9
0
        public void MovePolygon(JobInfo info)
        {
            if (Polygons.Count < 1)
                return;

            int index = info.GetRandomNumber(0, Polygons.Count);
            DnaPolygon poly = Polygons[index];
            Polygons.RemoveAt(index);
            index = info.GetRandomNumber(0, Polygons.Count);
            Polygons.Insert(index, poly);
            SetDirty();
        }
Beispiel #10
0
        public void AddPolygonClone(JobInfo info)
        {
            if (Polygons.Count < info.Settings.PolygonsMax)
            {
                if (Polygons.Count < 1)
                    AddPolygon(info);
                else
                {
                    DnaPolygon parent = Polygons[info.GetRandomNumber(0, Polygons.Count)];
                    var newPolygon = parent.Clone();
                    Polygons.Insert(Polygons.IndexOf(parent), newPolygon);

                    newPolygon.Offset(info.GetRandomNumber(-6, 6), info.GetRandomNumber(-6, 6));

                    newPolygon.Width = info.GetRandomNumber(1, 8);

                    SetDirty();
                }
            }
        }
Beispiel #11
0
        public void AddPolygon(JobInfo info)
        {
            if (Polygons.Count < info.Settings.PolygonsMax)
            {
                var newPolygon = new DnaPolygon();
                newPolygon.Init(this, info);

                int index = info.GetRandomNumber(0, Polygons.Count);

                Polygons.Insert(index, newPolygon);

                SetDirty();
            }
        }
Beispiel #12
0
        private void AddPoint(DnaDrawing drawing, JobInfo info)
        {
            if (Points.Count < info.Settings.PointsPerPolygonMax)
            {
                if (drawing.PointCount < info.Settings.PointsMax)
                {
                    var newPoint = new DnaPoint();

                    int index = info.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();
                }
            }
        }
Beispiel #13
0
        private void RemovePoint(DnaDrawing drawing, JobInfo info)
        {
            if (Points.Count > info.Settings.PointsPerPolygonMin)
            {
                if (drawing.PointCount > info.Settings.PointsMin)
                {
                    int index = info.GetRandomNumber(0, Points.Count);
                    Points.RemoveAt(index);

                    drawing.SetDirty();
                }
            }
        }
Beispiel #14
0
        public void Mutate(DnaDrawing drawing, JobInfo info)
        {
            if (info.WillMutate(info.Settings.AddPointMutationRate))
                AddPoint(drawing, info);

            if (info.WillMutate(info.Settings.RemovePointMutationRate))
                RemovePoint(drawing, info);

            if (info.WillMutate(info.Settings.FlipSplinesMutationRate))
                FlipSplines(drawing, info);

            if (info.WillMutate(info.Settings.FlipFilledMutationRate))
                FlipFilled(drawing, info);

            if (info.WillMutate(info.Settings.FlipFilledMutationRate))
                Width = info.GetRandomNumber(1, 8);

            Brush.Mutate(drawing, info);
            foreach(var point in Points)
            {
                point.Mutate(drawing, info);
            }

            //IsComplex = false;// checkComplex();
        }