private static void GenerateImage(ImageOutputConfiguration config, Dictionary <string, int> words, string baseName, int seed) { if (!config.IsEnabled) { return; } Console.Write("Generating cloud image..."); var width = config.Width; var height = config.Height; var rand = new Random(seed); var fontFamily = new FontFamily(config.Font); var collisionMap = new CollisionMap(width, height); var measurer = new StringMeasurer(); var minimumFontSize = config.MinimumFontSize; var compactness = config.Compactness; var placer = new WordPlacer(measurer, collisionMap, width, height, rand, fontFamily, minimumFontSize, compactness); var imageGenerator = new ImageGenerator(placer, width, height, fontFamily); var image = imageGenerator.Generate(words); image.Save(baseName); Console.WriteLine("[Done]"); }
public void ShouldContainAllGivenWords() { // Arrange var words = new List <KeyValuePair <string, int> > { new KeyValuePair <string, int>("three", 3), new KeyValuePair <string, int>("two", 2), new KeyValuePair <string, int>("one", 1) }; var rand = new Random(123); var map = Substitute.For <ICollisionMap>(); map.Check(Arg.Any <IEnumerable <RectangleF> >()).Returns(true); var measurer = Substitute.For <IStringMeasurer>(); measurer.Measure(Arg.Any <string>(), Arg.Any <Font>()) .Returns(inf => new StringMeasurement(inf.ArgAt <string>(0), new [] { RectangleF.Empty }, PointF.Empty)); var sut = new WordPlacer(measurer, map, 100, 100, rand, FontFamily.GenericMonospace, 10, 250); // Act var actual = sut.Place(words).ToList(); // Assert Assert.Equal(words.Count, actual.Count); }