document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public int GetError(IPictureMutation mutation)
  2. {
  3.     var picture = mutation.ApplyToPicture(algorithm.CurrentPicture);
  4.     var donePixels = new bool[algorithm.SourceData.Width,algorithm.SourceData.Height];
  5.     var totalError = 0;
  6.     totalError += ScorePolygons(donePixels, picture);
  7.     totalError += ScoreRemainingPixels(donePixels);
  8.     return totalError;
  9. }
  10.  
  11. int ScoreRemainingPixels(bool[,] donePixels)
  12. {
  13.     return algorithm.SourceData.GetPoints().Where(point => !donePixels[point.X, point.Y]).Sum(point => algorithm.SourceData[point].Length);
  14. }
  15.  
  16. int ScorePolygons(bool[,] donePixels, VectorPicture picture)
  17. {
  18.     var totalError = 0;
  19.     foreach (var polygon in picture.Polygons.ReverseEnumerable())
  20.     {
  21.         foreach (var point in drawer(polygon).Where(point => !donePixels[point.X, point.Y]))
  22.         {
  23.             donePixels[point.X, point.Y] = true;
  24.             totalError += algorithm.SourceData[point].GetAbsColorError(polygon.Color);
  25.         }
  26.     }
  27.     return totalError;
  28. }
');