Skip to content

Commit

Permalink
Написала классы TagsCloudVisualization и PointsOnSpiral
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasiakimura committed Dec 5, 2023
1 parent cd1a221 commit d4e16ed
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cs/TagsCloudVisualization/PointsOnSpiral.cs
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++;
}
}
}
29 changes: 29 additions & 0 deletions cs/TagsCloudVisualization/Program.cs
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);
}
}
10 changes: 10 additions & 0 deletions cs/TagsCloudVisualization/TagsCloudVisualization.csproj
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>
7 changes: 7 additions & 0 deletions cs/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
}
}
6 changes: 6 additions & 0 deletions cs/tdd.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BowlingGame", "BowlingGame\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "Samples\Samples.csproj", "{B5108E20-2ACF-4ED9-84FE-2A718050FC94}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TagsCloudVisualization", "TagsCloudVisualization\TagsCloudVisualization.csproj", "{21297E12-D769-413A-BDBE-7A1D2022B650}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{B5108E20-2ACF-4ED9-84FE-2A718050FC94}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B5108E20-2ACF-4ED9-84FE-2A718050FC94}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B5108E20-2ACF-4ED9-84FE-2A718050FC94}.Release|Any CPU.Build.0 = Release|Any CPU
{21297E12-D769-413A-BDBE-7A1D2022B650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{21297E12-D769-413A-BDBE-7A1D2022B650}.Debug|Any CPU.Build.0 = Debug|Any CPU
{21297E12-D769-413A-BDBE-7A1D2022B650}.Release|Any CPU.ActiveCfg = Release|Any CPU
{21297E12-D769-413A-BDBE-7A1D2022B650}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit d4e16ed

Please sign in to comment.