Conversation
…рживаясь SRP DIP OCD
…, она создается, удалил повторяющиеся тесты
|
|
||
| public abstract class CircularCloudLayouterBase(Point center) | ||
| { | ||
| public Point Center { get; init; } = center; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public abstract class CircularCloudLayouterBase(Point center) | ||
| { | ||
| public Point Center { get; init; } = center; | ||
| protected List<Rectangle> rectangles = []; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public class ArchimedeanSpiral(Point center) : ISpiral | ||
| { | ||
| private double angle; | ||
| private const double SpiralStep = 0.2; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
В целом исправление есть, но можешь объяснить, пожалуйста, на что влияет изменение этих параметров и как это можно использовать?
There was a problem hiding this comment.
spiralStep определяет насколько увеличивается угол при каждом шаге, а radiusStep определяет насколько быстро растет расстояние от центра.
Если увеличивать radiusStep - расширяем спираль, spiralStep - ускоряет проход по спирали, но меньше проверяет точки.
Т.е. увеличение параметров ускоряют поиск но повышают вероятность пропускать свободные поверхности и создавать дырки между прямоугольниками. А уменьшение - делают все более точным из за более мелких шагов
| { | ||
| var dx = Math.Sign(center.X - (rectangle.X + rectangle.Width / 2)); | ||
| var dy = Math.Sign(center.Y - (rectangle.Y + rectangle.Height / 2)); | ||
| if (dx == 0 && dy == 0) return rectangle; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| public class SimpleCollisionDetector : ICollisionDetector | ||
| { | ||
| public bool Intersects(Rectangle rectangle, IEnumerable<Rectangle> others) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public static void DrawRectangles(IEnumerable<Rectangle> rectangles, string outputPath, int width = 1500, | ||
| int height = 1500) | ||
| { | ||
| using var bitmap = new Bitmap(width, height); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Здесь я больше говорил не про конкретные значения, а про принцип. Т.е. почему 1.5к или 3к - достаточные значения?
There was a problem hiding this comment.
Сами значения принципиально не могут быть всегда достаточными, тут в основном такие значения, чтобы сам холст был большим и все прямоугольники помещались на нем. Также для большей детализации
There was a problem hiding this comment.
А что делать в случае, если поле недостаточно большое? Есть ли смысл отдельно обработать такой кейс?
|
|
||
| private Rectangle FindFreeRectangle(Size size) | ||
| { | ||
| while (true) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| using var graphics = Graphics.FromImage(bitmap); | ||
|
|
||
| graphics.Clear(Color.White); | ||
| using var pen = new Pen(Color.Blue, 2); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
cs/TagsCloudVisualization/Program.cs
Outdated
| var folderName = Path.Combine(desktopPath, "results"); | ||
| Directory.CreateDirectory(folderName); | ||
|
|
||
| GenerateExample("cloud1.png", new Size(20, 20), 100, folderName); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
|
||
| namespace TagsCloudLib.Visualizer; | ||
|
|
||
| public class TagCloudVisualizationConfig |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| public int BorderThickness { get; set; } = 2; | ||
|
|
||
| public Color FillColor { get; set; } = Color.FromArgb(80, Color.CornflowerBlue); | ||
| public bool UseFill { get; set; } = true; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Можно в будущем вынести отдельное поле, например, стиль
Реализовать паттерн стратегия со стилями и уже применять нужные нам
| var rect = layouterWithFake.PutNextRectangle(new Size(10, 10)); | ||
| rect.Center().Should().Be(freePoint); | ||
| } | ||
|
|
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@Luvr681