-
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.
- Loading branch information
smarthome
committed
Aug 3, 2023
1 parent
f0e1686
commit 666811a
Showing
3 changed files
with
62 additions
and
8 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,22 @@ | ||
namespace FamilyTree | ||
{ | ||
public static class ModelMock | ||
{ | ||
public static Person Create(int numberOfGenerations) | ||
{ | ||
return create(numberOfGenerations, 1); | ||
} | ||
|
||
private static Person create(int currentGeneration, int extend) | ||
{ | ||
if(currentGeneration == 0) | ||
return new Person($"Name{extend}", $"FamilyName{extend}", 1900 + extend, 2100 - extend, false, null, null); | ||
else | ||
{ | ||
var person1 = create(currentGeneration - 1, extend * 2); | ||
var person2 = create(currentGeneration - 1, extend * 2 + 1); | ||
return new Person($"Name{extend}", $"FamilyName{extend}", 1900 + extend, 2100 - extend, false, person1, person2); | ||
} | ||
} | ||
} | ||
} |
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,27 @@ | ||
using Svg; | ||
using System.Drawing; | ||
using System.Linq; | ||
|
||
namespace FamilyTree | ||
{ | ||
public static class Plotter | ||
{ | ||
public static SvgDocument Plot(Person model, int numberOfGenerations) | ||
{ | ||
var outerRadius = MathHelper.GetCreateRadii(numberOfGenerations).Last() + 20; | ||
var size = new SizeF(2 * outerRadius, 2 * outerRadius); | ||
var document = new SvgDocument(); | ||
document.Width = size.Width; | ||
document.Height = size.Height; | ||
document.Ppi = 96; | ||
|
||
var centre = new PointF(outerRadius, outerRadius); | ||
|
||
RayPlotter.PlotRays(document, centre, numberOfGenerations); | ||
CirclePlotter.PlotCircles(document, centre, numberOfGenerations); | ||
TextPlotter.PlotText(document, centre, model, numberOfGenerations); | ||
|
||
return document; | ||
} | ||
} | ||
} |
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