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(); } }
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); }
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); }
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(); } } }
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); }
internal static int Randomize(this int self,JobInfo info, int min, int max) { return self + info.GetRandomNumber(min, max); }
internal void Init(DnaDrawing drawing,JobInfo info) { X = info.GetRandomNumber(0, info.SourceImage.Width); Y = info.GetRandomNumber(0, info.SourceImage.Height); }
public void RemovePolygon(JobInfo info) { if (Polygons.Count > info.Settings.PolygonsMin) { int index = info.GetRandomNumber(0, Polygons.Count); Polygons.RemoveAt(index); SetDirty(); } }
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(); }
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(); } } }
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(); } }
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(); } } }
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(); } } }
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(); }