/// <inheritdoc /> public IData Generate(Dictionary <string, int> words) { var wordList = words.OrderByDescending(w => w.Value); var placements = Placer.Place(wordList); var img = new Bitmap(Width, Height); using (var gfx = Graphics.FromImage(img)) { gfx.TextRenderingHint = TextRenderingHint.AntiAlias; gfx.CompositingQuality = CompositingQuality.HighQuality; gfx.InterpolationMode = InterpolationMode.HighQualityBicubic; gfx.PixelOffsetMode = PixelOffsetMode.HighQuality; gfx.SmoothingMode = SmoothingMode.AntiAlias; gfx.Clear(Color.White); foreach (var wordPlacement in placements) { using (var path = new GraphicsPath()) { var matrix = new Matrix(); matrix.Translate(wordPlacement.Position.X, wordPlacement.Position.Y); path.AddString(wordPlacement.Word, FontFamily, (int)FontStyle.Regular, wordPlacement.FontSize, Point.Empty, StringMeasurer.StringFormat); path.Transform(matrix); var color = ColorMap[Rand.Next(0, ColorMap.Count)]; gfx.DrawPath(new Pen(color), path); gfx.FillPath(new SolidBrush(color), path); } } } return(new ImageData(img)); }