Skip to content

Бессараб Дмитрий#259

Open
d2em0n wants to merge 12 commits intokontur-courses:masterfrom
d2em0n:master
Open

Бессараб Дмитрий#259
d2em0n wants to merge 12 commits intokontur-courses:masterfrom
d2em0n:master

Conversation

@d2em0n
Copy link

@d2em0n d2em0n commented Nov 15, 2024

@PashaSoldatov (https://t.me/PashaSoldatov)

Comment on lines 24 to 25
if (!next.Equals(current))
{

Choose a reason for hiding this comment

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

А точно это проверка нужна?

Comment on lines 12 to 14
[TestFixture]
public class ArchemedianSpiral_Should
{

Choose a reason for hiding this comment

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

Можно еще тест что центр это первая точка

Comment on lines 20 to 22
if (center.X > 0 && center.Y > 0)
Center = center;
else throw new ArgumentException("Center coordinates values have to be greater than Zero");

Choose a reason for hiding this comment

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

лучше заминить условие на провиположное и тогда не нужно будет писать else

Comment on lines 54 to 60
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;
}

Choose a reason for hiding this comment

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

А зачем выделяем отдельно обработку первого прямоугольника?

Comment on lines 15 to 47
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");
}
}

Choose a reason for hiding this comment

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

Вижу копирование, а отличие толкьо точками на вход и путем до изображения

Comment on lines 10 to 13
namespace TagsCloudVisualization
{
[TestFixture]
public class ArchemedianSpiral_Should

Choose a reason for hiding this comment

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

Тесты желательно уносить в отдельную сборку

Comment on lines 33 to 34
DrawRectangle(image, layout.PutNextRectangle(size));
image.Save(@"c:\\Images\\2.bmp");

Choose a reason for hiding this comment

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

лучше задавать относительне пути от запуска. Допустим не у всех есть диск c

Comment on lines 24 to 42
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);
}

Choose a reason for hiding this comment

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

Кажется получилось много дублирующи конструкторов

Comment on lines 35 to 37

public CircularCloudLayouter(Point center, Func<Point, IEnumerable<Point>> pointGenerator) : this(center)
{

Choose a reason for hiding this comment

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

Почему на вход не интерфейс IPointGenerator принимаешь?

Comment on lines 76 to 77
return others.Select(x => x.IntersectsWith(supposed))
.Any(x => x == true);

Choose a reason for hiding this comment

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

можно просто .Any()

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