public PlacedWordRectangle(PlacedWordRectangle placedRectangle)
     : base(placedRectangle)
 {
     Position = placedRectangle.Position;
 }
 static PlacedWordRectangle SwapViewCoordinates(PlacedWordRectangle rectangle)
 {
     var newRectangle = new WordRectangle(rectangle.Word, rectangle.Font, SwapSizeElements(rectangle.Size));
     return new PlacedWordRectangle(newRectangle, SwapPointCoordinates(rectangle.Position));
 }
        PlacedWordRectangle PlaceNextWord(WordRectangle rectangle,
            IReadOnlyList<PlacedWordRectangle> alreadyPlacedWords)
        {
            if (rectangle.Size.Width > Size.Width || rectangle.Size.Height > Size.Height)
                return null;

            var triesCount = Math.Max(50, alreadyPlacedWords.Count * 2);
            PlacedWordRectangle bestRectangle = null;
            double? bestRate = null;
            for (var i = 0; i < triesCount; i++)
            {
                var placeMethod = placeMethods[random.Next(placeMethods.Length)];
                var position = placeMethod(rectangle.Size, alreadyPlacedWords);
                if (position == null)
                    continue;
                var view = new PlacedWordRectangle(rectangle, position.Value);

                var rate = DistanceSquareBetween(GetViewCenter(view), imageCenter);
                if (bestRate == null || rate < bestRate)
                {
                    bestRectangle = view;
                    bestRate = rate;
                }
            }
            return bestRectangle;
        }
 static PointF GetViewCenter(PlacedWordRectangle rectangle)
 {
     return new PointF(rectangle.Position.X + rectangle.Size.Width / 2.0f,
                       rectangle.Position.Y + rectangle.Size.Height / 2.0f);
 }
 public WordView(PlacedWordRectangle placedRectangle, Color color)
     : base(placedRectangle)
 {
     Color = color;
 }