forked from kontur-courses/tdd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Написала классы TagsCloudVisualization и PointsOnSpiral
- Loading branch information
1 parent
cd1a221
commit d4e16ed
Showing
5 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Drawing; | ||
|
||
namespace TagsCloudVisualization; | ||
|
||
public class PointsOnSpiral | ||
{ | ||
private Point center; | ||
|
||
public PointsOnSpiral(Point center) | ||
{ | ||
this.center = center; | ||
} | ||
|
||
public IEnumerable<Point> GetPointsOnSpiral() | ||
{ | ||
var radius = 0; | ||
while (true) | ||
{ | ||
for (var i = 0; i < 360; i++) | ||
{ | ||
yield return new Point((int)(Math.Cos(2 * Math.PI * i / 360) * radius) + center.X, | ||
(int)(Math.Sin(2 * Math.PI * i / 360) * radius) + center.Y); | ||
} | ||
|
||
radius++; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Drawing; | ||
using TagsCloudVisualization; | ||
|
||
class CircularCloudLayouter | ||
{ | ||
private Point cloudCenter; | ||
private List<Rectangle> rectangels = new List<Rectangle>(); | ||
private PointsOnSpiral points; | ||
|
||
public CircularCloudLayouter(Point cloudCenter) | ||
{ | ||
this.cloudCenter = cloudCenter; | ||
points = new PointsOnSpiral(cloudCenter); | ||
} | ||
|
||
public Rectangle PutNextRectangle(Size rectangleSize) | ||
{ | ||
foreach (var point in points.GetPointsOnSpiral()) | ||
{ | ||
var rectangle = new Rectangle(point, rectangleSize); | ||
if (rectangels.Any(x => x.IntersectsWith(rectangle))) | ||
continue; | ||
rectangels.Add(rectangle); | ||
return rectangle; | ||
} | ||
|
||
return new Rectangle(cloudCenter, rectangleSize); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "8.0.0", | ||
"rollForward": "latestMajor", | ||
"allowPrerelease": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters