Conversation
| if (!next.Equals(current)) | ||
| { |
| [TestFixture] | ||
| public class ArchemedianSpiral_Should | ||
| { |
There was a problem hiding this comment.
Можно еще тест что центр это первая точка
| if (center.X > 0 && center.Y > 0) | ||
| Center = center; | ||
| else throw new ArgumentException("Center coordinates values have to be greater than Zero"); |
There was a problem hiding this comment.
лучше заминить условие на провиположное и тогда не нужно будет писать else
| if (Rectangles.Count == 0) | ||
| { | ||
| var firstRectangle = new Rectangle(new Point(Center.X - rectangleSize.Width / 2, | ||
| Center.Y - rectangleSize.Height / 2), rectangleSize); | ||
| Rectangles.Add(firstRectangle); | ||
| return firstRectangle; | ||
| } |
There was a problem hiding this comment.
А зачем выделяем отдельно обработку первого прямоугольника?
TagsCloudVisualization/Drawings.cs
Outdated
| var rectangleSizes = new RandomSizeRectangle(). | ||
| GenerateRectangles(300); | ||
| var layout = new CircularCloudLayouter(new Point(1000, 1000)); | ||
| var image = new Bitmap(layout.Size.Width, layout.Size.Height); | ||
| foreach (var size in rectangleSizes) | ||
| { | ||
| DrawRectangle(image, layout.PutNextRectangle(size)); | ||
| image.Save(@"c:\\Images\\1.bmp"); | ||
| } | ||
|
|
||
|
|
||
| rectangleSizes = new RandomSizeRectangle(). | ||
| GenerateRectangles(300); | ||
| var points = new HeartShaped().GeneratePoints(new Point(1000, 1000)); | ||
| layout = new CircularCloudLayouter(new Point(1000, 1000), points); | ||
| image = new Bitmap(layout.Size.Width, layout.Size.Height); | ||
| foreach (var size in rectangleSizes) | ||
| { | ||
| DrawRectangle(image, layout.PutNextRectangle(size)); | ||
| image.Save(@"c:\\Images\\2.bmp"); | ||
| } | ||
|
|
||
| rectangleSizes = new RandomSizeRectangle(). | ||
| GenerateRectangles(300); | ||
| //points = new DeltaSHaped().GeneratePoints(new Point(1000, 1000)); | ||
| layout = new CircularCloudLayouter(new Point(1000, 1000), new DeltaSHaped().GeneratePoints); | ||
| image = new Bitmap(layout.Size.Width, layout.Size.Height); | ||
| foreach (var size in rectangleSizes) | ||
| { | ||
| DrawRectangle(image, layout.PutNextRectangle(size)); | ||
| image.Save(@"c:\\Images\\3.bmp"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Вижу копирование, а отличие толкьо точками на вход и путем до изображения
| namespace TagsCloudVisualization | ||
| { | ||
| [TestFixture] | ||
| public class ArchemedianSpiral_Should |
There was a problem hiding this comment.
Тесты желательно уносить в отдельную сборку
TagsCloudVisualization/Drawings.cs
Outdated
| DrawRectangle(image, layout.PutNextRectangle(size)); | ||
| image.Save(@"c:\\Images\\2.bmp"); |
There was a problem hiding this comment.
лучше задавать относительне пути от запуска. Допустим не у всех есть диск c
| Rectangles = []; | ||
| _points = new ArchemedianSpiral().GeneratePoints(Center); | ||
| } | ||
|
|
||
| public CircularCloudLayouter(Point center, IEnumerable<Point> points) : this(center) | ||
| { | ||
| Center = center; | ||
| Size = CountSize(center); | ||
| Rectangles = []; | ||
| _points = points; | ||
| } | ||
|
|
||
| public CircularCloudLayouter(Point center, Func<Point, IEnumerable<Point>> pointGenerator) : this(center) | ||
| { | ||
| Center = center; | ||
| Size = CountSize(center); | ||
| Rectangles = []; | ||
| _points = pointGenerator(Center); | ||
| } |
There was a problem hiding this comment.
Кажется получилось много дублирующи конструкторов
|
|
||
| public CircularCloudLayouter(Point center, Func<Point, IEnumerable<Point>> pointGenerator) : this(center) | ||
| { |
There was a problem hiding this comment.
Почему на вход не интерфейс IPointGenerator принимаешь?
| return others.Select(x => x.IntersectsWith(supposed)) | ||
| .Any(x => x == true); |
@PashaSoldatov (https://t.me/PashaSoldatov)