public override GAShape Duplicate(GARepresentation newowner) { GAShapeCurve newgap = new GAShapeCurve(newowner); newgap.ShapeColour = this.ShapeColour; newgap.Width = Width; newgap.Tension = Tension; foreach (PointF p in PolyPoints) { newgap.PolyPoints.Add(new PointF(p.X, p.Y)); } return(newgap); }
public static GAShape CreateRandom(ThreadSafeRandom rd, GAProjectProperties prop, GARepresentation owner) { List <GAShapeType> lt = new List <GAShapeType>(); if (prop.UsePoints) { lt.Add(GAShapeType.Circle); } if (prop.UseLines) { lt.Add(GAShapeType.Line); } if (prop.UseCurves) { lt.Add(GAShapeType.Curve); } if (prop.UseFilledPolygons) { lt.Add(GAShapeType.FilledPolygon); } if (prop.UseFilledPolycurves) { lt.Add(GAShapeType.FilledPolycurve); } //if (prop.UsePaths) lt.Add(GAShapeType.Path); if (lt.Count == 0) { throw new Exception("GASHape.CreateRandom - No Shapes Allowed"); } GAShape output = null; switch (lt[rd.Next(lt.Count)]) { case GAShapeType.Circle: output = new GAShapeCircle(owner); break; case GAShapeType.Line: output = new GAShapeLine(owner); break; case GAShapeType.Curve: output = new GAShapeCurve(owner); break; case GAShapeType.FilledPolygon: output = new GAShapeFilledPolygon(owner); break; case GAShapeType.FilledPolycurve: output = new GAShapeFilledPolycurve(owner); break; case GAShapeType.Path: output = new GAShapePath(owner); break; } output.Randomize(rd, prop); return(output); }