Skip to content

Якшибаев Данил#264

Open
gogy4 wants to merge 14 commits intokontur-courses:masterfrom
gogy4:master
Open

Якшибаев Данил#264
gogy4 wants to merge 14 commits intokontur-courses:masterfrom
gogy4:master

Conversation

@gogy4
Copy link

@gogy4 gogy4 commented Nov 25, 2025


public abstract class CircularCloudLayouterBase(Point center)
{
public Point Center { get; init; } = center;

This comment was marked as resolved.

public abstract class CircularCloudLayouterBase(Point center)
{
public Point Center { get; init; } = center;
protected List<Rectangle> rectangles = [];

This comment was marked as resolved.

public class ArchimedeanSpiral(Point center) : ISpiral
{
private double angle;
private const double SpiralStep = 0.2;

This comment was marked as resolved.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

В целом исправление есть, но можешь объяснить, пожалуйста, на что влияет изменение этих параметров и как это можно использовать?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


public class SimpleCollisionDetector : ICollisionDetector
{
public bool Intersects(Rectangle rectangle, IEnumerable<Rectangle> others)

This comment was marked as resolved.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь я больше говорил не про конкретные значения, а про принцип. Т.е. почему 1.5к или 3к - достаточные значения?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сами значения принципиально не могут быть всегда достаточными, тут в основном такие значения, чтобы сам холст был большим и все прямоугольники помещались на нем. Также для большей детализации

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что делать в случае, если поле недостаточно большое? Есть ли смысл отдельно обработать такой кейс?


private Rectangle FindFreeRectangle(Size size)
{
while (true)

This comment was marked as resolved.

using var graphics = Graphics.FromImage(bitmap);

graphics.Clear(Color.White);
using var pen = new Pen(Color.Blue, 2);

This comment was marked as resolved.

var folderName = Path.Combine(desktopPath, "results");
Directory.CreateDirectory(folderName);

GenerateExample("cloud1.png", new Size(20, 20), 100, folderName);

This comment was marked as resolved.


namespace TagsCloudLib.Visualizer;

public class TagCloudVisualizationConfig

This comment was marked as resolved.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно в будущем вынести отдельное поле, например, стиль
Реализовать паттерн стратегия со стилями и уже применять нужные нам

var rect = layouterWithFake.PutNextRectangle(new Size(10, 10));
rect.Center().Should().Be(freePoint);
}

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants