-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Бессараб Дмитрий #259
base: master
Are you sure you want to change the base?
Бессараб Дмитрий #259
Conversation
if (!next.Equals(current)) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А точно это проверка нужна?
[TestFixture] | ||
public class ArchemedianSpiral_Should | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно еще тест что центр это первая точка
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше заминить условие на провиположное и тогда не нужно будет писать 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем выделяем отдельно обработку первого прямоугольника?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вижу копирование, а отличие толкьо точками на вход и путем до изображения
namespace TagsCloudVisualization | ||
{ | ||
[TestFixture] | ||
public class ArchemedianSpiral_Should |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тесты желательно уносить в отдельную сборку
TagsCloudVisualization/Drawings.cs
Outdated
DrawRectangle(image, layout.PutNextRectangle(size)); | ||
image.Save(@"c:\\Images\\2.bmp"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше задавать относительне пути от запуска. Допустим не у всех есть диск 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется получилось много дублирующи конструкторов
|
||
public CircularCloudLayouter(Point center, Func<Point, IEnumerable<Point>> pointGenerator) : this(center) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему на вход не интерфейс IPointGenerator принимаешь?
return others.Select(x => x.IntersectsWith(supposed)) | ||
.Any(x => x == true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно просто .Any()
@PashaSoldatov (https://t.me/PashaSoldatov)