static void MoveShape( Random rand, Shape shape, TaskState task )
{
RectangleF rect = shape.GetBoundaries();
int maxOverlap = task.ProjectOptions.MaxOverlap;
PointF delta = new PointF {
X =
rand.NextFloat( Math.Max( -maxOverlap, -rect.X - maxOverlap ),
Math.Min( maxOverlap, task.ImageWidth - rect.Right + maxOverlap ) ),
Y =
rand.NextFloat( Math.Max( -maxOverlap, -rect.Y - maxOverlap ),
Math.Min( maxOverlap, task.ImageHeight - rect.Bottom + maxOverlap ) )
};
for( int i = 0; i < shape.Points.Length; i++ ) {
shape.Points[i].X += delta.X;
shape.Points[i].Y += delta.Y;
}
}