示例#1
0
 public Result <Bitmap> CreateImage(IEnumerable <string> words, TagCloudCreationOptions options)
 {
     return(PrepareWords(words, options)
            .Then(ws => generator.GenerateStats(ws))
            .Then(PrepareStats)
            .Then(wis => imageCreator.CreateTagCloudImage(wis, options.ImageOptions)));
 }
示例#2
0
        public Bitmap CreateImage(IEnumerable <string> words, TagCloudCreationOptions options)
        {
            words = preparers.Aggregate(words, (current, wordPreparer) => current
                                        .Select(w => wordPreparer.PrepareWord(w, options))
                                        .Where(wi => wi != null)
                                        .Where(w => w != "")
                                        .ToList());

            var stats = generator.GenerateStats(words);

            var maxCount = stats.Max(w => w.Count);
            var minCount = stats.Min(w => w.Count);

            var wordPairs = stats.OrderByDescending(wi => wi.Count)
                            .Select(wordInfo => wordInfo.With(GetScale(wordInfo.Count, maxCount, minCount)));

            return(imageCreator.CreateTagCloudImage(wordPairs, options.ImageOptions));
        }