public TAMImageDiagram Generate(TAMImageDiagram baseDiagram, TAMTone tone, TAMMipmapLevel mipmapLevel, int seed) { _strokesGenerator.ResetSeed(seed); _random = new System.Random(seed); var diagram = baseDiagram.Copy(); float currentCoverage = ComputeCoverage(diagram, mipmapLevel); float targetCoverage = _generationConfiguration.TargetCoverages[tone]; while (targetCoverage > currentCoverage) { List <RankedPossibleStroke> possibleStrokes = new List <RankedPossibleStroke>(); for (int i = 0; i < _generationConfiguration.TriesCount[mipmapLevel]; i++) { TAMStroke newStroke = _strokesGenerator.CreateRandomStroke(new Vector2(_random.Next(), _random.Next()), tone); RankedPossibleStroke rankedNewStroke = RankStroke(newStroke, diagram); possibleStrokes.Add(rankedNewStroke); } var bestStroke = possibleStrokes.OrderBy(p => p.Rank).First(); diagram.AddStroke(bestStroke.Stroke); currentCoverage = ComputeCoverage(diagram, mipmapLevel); } return(diagram); }
public TAMImageDiagram Generate(TAMImageDiagram diagram, TAMTone tone, TAMMipmapLevel mipmapLevel, int seed) { List <Vector2> currentPoints = diagram.Strokes.Select(c => c.Center).ToList(); var newPoints = _sampler.Generate(_configuration.GenerationCount, _configuration.ExclusionZoneValues[tone][mipmapLevel], seed, currentPoints); return(new TAMImageDiagram(diagram.Strokes.Union(newPoints.Select(c => _strokesGenerator.CreateRandomStroke(c, tone))).ToList())); }