SuperImageEvolver.Shape.GetBoundaries C# (CSharp) Méthode

GetBoundaries() public méthode

public GetBoundaries ( ) : RectangleF
Résultat System.Drawing.RectangleF
        public RectangleF GetBoundaries()
        {
            RectangleF rect = new RectangleF( int.MaxValue, int.MaxValue, 0, 0 );
            for( int i = 0; i < Points.Length; i++ ) {
                rect.X = Math.Min( rect.X, Points[i].X );
                rect.Y = Math.Min( rect.Y, Points[i].Y );
                rect.Width = Math.Max( rect.Width, Points[i].X );
                rect.Height = Math.Max( rect.Height, Points[i].Y );
            }
            rect.Width -= rect.X;
            rect.Height -= rect.Y;
            return rect;
        }

Usage Example

Exemple #1
0
        public DNA Initialize(Random rand, TaskState task)
        {
            var dna = new DNA {
                Shapes = new Shape[task.Shapes]
            };

            for (int s = 0; s < task.Shapes; s++)
            {
                var shape = new Shape {
                    Color  = Color.FromArgb(StartingAlpha, Color.R, Color.G, Color.B),
                    Points = new PointF[task.Vertices]
                };
                int maxRadius = (int)Math.Round(Math.Min(task.ImageWidth, task.ImageHeight) * MaxRadiusRatio);
                int radius    = rand.Next(MinRadius, maxRadius);
                var center    = new Point(rand.Next(radius - MaxOverlap, task.ImageWidth - radius + MaxOverlap),
                                          rand.Next(radius - MaxOverlap, task.ImageHeight - radius + MaxOverlap));
                for (int v = 0; v < task.Vertices; v++)
                {
                    double t = v * Math.PI * 2 * Revolutions / task.Vertices + Angle * Math.PI * 2 + Math.PI / task.Vertices;
                    shape.Points[v].X = (float)(center.X + Math.Cos(t) * radius);
                    shape.Points[v].Y = (float)(center.Y + Math.Sin(t) * radius);
                }
                if (shape.GetBoundaries().Width < 1 || shape.GetBoundaries().Height < 1)
                {
                    continue;
                }
                dna.Shapes[s] = shape;
            }
            return(dna);
        }
All Usage Examples Of SuperImageEvolver.Shape::GetBoundaries