private Result <IEnumerable <Tag> > CheckTagsFitOnImage(IRectanglesLayouter layouter, IEnumerable <Tag> tags) { tags = tags.ToList(); var layoutSize = layouter.GetLayoutSize(); var subtraction = imageConfig.ImageSize - layoutSize; if (subtraction.Width < 0 || subtraction.Height < 0) { return(Result.Fail <IEnumerable <Tag> >( $"Cloud out of size image:\n Cloud size: {layoutSize}\n Image size: {imageConfig.ImageSize}")); } return(Result.Ok(tags)); }
private Result <IEnumerable <Tag> > GetTagsFormWords(IRectanglesLayouter layouter, IEnumerable <WordInfo> words) { var count = 30; return(Result.Ok(words.OrderByDescending(info => info.Frequence) .Take(count) .Select((wordInfo, index) => { using var font = new Font(wordsConfig.Font.FontFamily, count - index / 2); var size = TextRenderer.MeasureText(wordInfo.Word, font); return new Tag(wordInfo.Word, layouter.PutNextRectangle(size), new FontConfig(font.FontFamily, font.Size)); })) .Then(tags => CheckTagsFitOnImage(layouter, tags))); }
public void SetNewLayouter(IRectanglesLayouter newLayouter) { layouter = newLayouter; }
public TagsCloudDrawer(IRectanglesLayouter layouter, TagsCloudSettings tagsCloudSettings) { this.layouter = layouter; this.tagsCloudSettings = tagsCloudSettings; }