public void MatrixSeed(Bitmap seed, GAProjectProperties prop) { Shapes.Clear(); int plug = prop.Granularity / 2; for (int x = 0; x < MaxX; x += prop.Granularity) { for (int y = 0; y < MaxY; y += prop.Granularity) { GAShapeFilledPolycurve gap = new GAShapeFilledPolycurve(this); Color c = seed.GetPixel(Math.Min(x + plug, MaxX - 1), Math.Min(y + plug, MaxY - 1)); gap.ShapeColour = Color.FromArgb(128, c.R, c.G, c.B); if ((gap.ShapeColour.ToArgb() & 0xFFFFFF) != (BackgroundColour.ToArgb() & 0xFFFFFF)) { if (prop.MatrixSeedingType == GAMatrixSeedingType.Blocks) { InitSeedBlocks(prop.Granularity, x, y, gap); } if (prop.MatrixSeedingType == GAMatrixSeedingType.Circles) { InitSeedCircles(prop.Granularity, x, y, gap); } Shapes.Add(gap); } } } UpdateTotalPoints(); }
public override GAShape Duplicate(GARepresentation newowner) { GAShapeFilledPolycurve newgap = new GAShapeFilledPolycurve(newowner); newgap.ShapeColour = this.ShapeColour; 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); }