//init polygon public void init() { Points = new List <MyDnaPoint>(); var origin = new MyDnaPoint(); origin.init(); for (int i = 0; i < PointsPerPolygonMin; i++) { var point = new MyDnaPoint(); point.x = Math.Min(Math.Max(0, origin.x + getRandomNumber(-3, 3)), MaxWidth); point.y = Math.Min(Math.Max(0, origin.y + getRandomNumber(-3, 3)), MaxHeight); Points.Add(point); } //fill polygon using our Brush Brush = new MyDnaBrush(); Brush.init(); }
//adding points in polygon //modify polygon with adding points (make from 3th(min) -> 5th edges ) private void addPoint(MyDnaDrawing drawing) { if (Points.Count < PointsPerPolygonMax) { if (drawing.pointCount < PointsMax) { var newPoint = new MyDnaPoint(); int index = getRandomNumber(1, Points.Count - 1); MyDnaPoint prev = Points[index - 1]; MyDnaPoint next = Points[index]; newPoint.x = (prev.x + next.x) / 2; newPoint.y = (prev.y + next.y) / 2; Points.Insert(index, newPoint); drawing.setDefect(); } } }