Esempio n. 1
0
        public void CanFillRectangleWithRectangles_ShouldBeFalse_WhenCanNotFill(
            int mainWidth, int mainHeight, int innerWidth, int innerHeight, int count)
        {
            var mainSize  = new Size(mainWidth, mainHeight);
            var innerSize = new Size(innerWidth, innerHeight);

            var result = SizeUtils.CanFillSizeWithSizes(mainSize, innerSize, count);

            result.Should().BeFalse();
        }
Esempio n. 2
0
        private float GetMaxWordFontSize(Word mostFrequentWord, int wordsCount, PictureConfig pictureConfig)
        {
            var currentSize = SizeUtils.GetWordBasedSize(
                mostFrequentWord.Value, pictureConfig.FontFamily, minFontSize);

            if (!SizeUtils.CanFillSizeWithSizes(
                    pictureConfig.Size, currentSize, wordsCount))
            {
                throw new ArgumentException(
                          $"Picture size {pictureConfig.Size.Width}x{pictureConfig.Size.Height} is too small for this word set");
            }

            var currentFontSize = minFontSize;

            while (SizeUtils.CanFillSizeWithSizes(pictureConfig.Size, currentSize, wordsCount) &&
                   2 * currentSize.Width < pictureConfig.Size.Width)
            {
                currentFontSize++;
                currentSize =
                    SizeUtils.GetWordBasedSize(mostFrequentWord.Value, pictureConfig.FontFamily, currentFontSize);
            }

            return(currentFontSize - 1);
        }