Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        protected float NextFloat(ThreadSafeRandom rd, float max)
        {
            float trx = (float)rd.Next() / (float)int.MaxValue;

            return(max * trx);
        }
Esempio n. 3
0
 private void RemoveRandomPoint(ThreadSafeRandom rd)
 {
     PolyPoints.RemoveAt(rd.Next(PolyPoints.Count));
 }
Esempio n. 4
0
 public override void Randomize(ThreadSafeRandom rd, GAProjectProperties prop)
 {
     PolyPoints[0] = GetRandomPoint(rd, prop);
     ShapeColour   = Color.FromArgb(rd.Next(255), rd.Next(255), rd.Next(255), rd.Next(255));
     Size          = rd.Next(prop.MaxPointMovement) + 1;
 }
Esempio n. 5
0
        private void AddRandomPoint(ThreadSafeRandom rd, GAProjectProperties prop)
        {
            PointF p = GetRandomPoint(rd, prop);

            PolyPoints.Insert(rd.Next(PolyPoints.Count), p);
        }