Esempio n. 1
0
        private void Paint(IEnumerable <IWord> wordsToDraw, string saveImageLocation)
        {
            var layout = new LayoutFactory().CreateLayout(Size, LayoutType);
            var toDraw = wordsToDraw as IList <IWord> ?? wordsToDraw.ToList();
            var minMax = CaclulateMinMaxWordWeights(toDraw);
            var bitmap = new Bitmap(Size.Width, Size.Height);

            bitmap.SetResolution(Convert.ToInt32(Size.Width / 6), Convert.ToInt32(Size.Height / 6));
            var graphics = Graphics.FromImage(bitmap);

            graphics.Clear(GetRandomBackgroundColor());
            var graphicEngine = new GdiGraphicEngine(graphics, FontFamily, FontStyle,
                                                     ColorPalette, MinFontSize, MaxFontSize, minMax.Min, minMax.Max);

            layout.Arrange(toDraw, graphicEngine);
            SaveFile(bitmap, saveImageLocation);
        }