Exemplo n.º 1
0
        public void CreateImage(IInitialSettings settings)
        {
            var words          = reader.ReadWords(settings.InputFilePath);
            var wordsWithCount = wordProcessor.ProcessWords(words).ToList();
            var sizes          = converter.ConvertToSizes(wordsWithCount);
            var rectangles     = layouter.GetRectangles(sizes);
            var imageSize      = settings.ImageSize;

            if (imageSize == Size.Empty)
            {
                imageSize = imageSizeCalculator.CalculateImageSize(rectangles);
            }
            rectangles = rectanglesTransformer.TransformRectangles(rectangles, imageSize);
            words      = wordsWithCount.Select(e => e.Word);
            var wordRectangles = words.Zip(rectangles, (w, r) => new WordRectangle(w, r)).ToList();
            var image          = visualizer.DrawImage(wordRectangles, imageSize);

            saver.SaveImage(image, settings.OutputFilePath);
        }
Exemplo n.º 2
0
        private List <WordRectangle> GetWordRectangles(IEnumerable <string> words, IEnumerable <Rectangle> rectangles, Size imageSize)
        {
            var transformedRectangles = rectanglesTransformer.TransformRectangles(rectangles, imageSize);

            return(words.Zip(transformedRectangles, (w, r) => new WordRectangle(w, r)).ToList());
        }