Skip to content

Commit 9c043ac

Browse files
committed
Implemented Root-Phi rectangle
1 parent 9741b6d commit 9c043ac

3 files changed

Lines changed: 25 additions & 8 deletions

File tree

Src/ScreenGrid.Models/Grids/GridCreator.cs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,29 @@ public static IEnumerable<Line> CreateGrid(GridType gridType, double width, doub
415415

416416
return lines;
417417
}
418-
////case GridType.RootPhiRectangle:
419-
//// {
420-
//// var rectangle = CalculateDynamicRectangleExtents(RatioConstants.RootPhi / RatioConstants.One, actualAspectRatio);
421-
//// // TODO: armature
422-
//// return CreateRootNRectangle(rectangle);
423-
//// }
418+
case GridType.RootPhiRectangle:
419+
{
420+
var rectangle = CalculateDynamicRectangleExtents(RatioConstants.RootPhi / RatioConstants.One, actualAspectRatio);
421+
var lines = CreateRectangleWithMainDiagonals(rectangle);
422+
423+
var w = rectangle.Width / (RatioConstants.RootPhi * RatioConstants.RootPhi);
424+
var h = rectangle.Height / (RatioConstants.RootPhi * RatioConstants.RootPhi);
425+
426+
lines.Add(new Line(rectangle.Left + w, rectangle.Top, rectangle.Left + w, rectangle.Bottom));
427+
lines.Add(new Line(rectangle.Right - w, rectangle.Top, rectangle.Right - w, rectangle.Bottom));
428+
lines.Add(new Line(rectangle.Left, rectangle.Top + h, rectangle.Right, rectangle.Top + h));
429+
lines.Add(new Line(rectangle.Left, rectangle.Bottom - h, rectangle.Right, rectangle.Bottom - h));
430+
431+
// Left
432+
lines.Add(new Line(rectangle.Left, rectangle.Top, rectangle.Left + w, rectangle.Bottom));
433+
lines.Add(new Line(rectangle.Left, rectangle.Bottom, rectangle.Left + w, rectangle.Top));
434+
435+
// Right
436+
lines.Add(new Line(rectangle.Right, rectangle.Top, rectangle.Right - w, rectangle.Bottom));
437+
lines.Add(new Line(rectangle.Right, rectangle.Bottom, rectangle.Right - w, rectangle.Top));
438+
439+
return lines;
440+
}
424441
case GridType.Root2Rectangle:
425442
{
426443
var rectangle = CalculateDynamicRectangleExtents(RatioConstants.Root2 / RatioConstants.One, actualAspectRatio);

Src/ScreenGrid.Models/Grids/GridModeItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static IEnumerable<GridModeItem> List
5050
new GridModeItem(GridType.GoldenSpiralStretched, "Golden Spiral (stretched)"),
5151
new GridModeItem(GridType.OneDotFiveRectangle, "1.5 Rectangle"),
5252
new GridModeItem(GridType.GoldenRectangle, "Golden (Phi) Rectangle"),
53-
// TODO: new GridModeItem(GridType.RootPhiRectangle, "Root-Phi Rectangle"),
53+
new GridModeItem(GridType.RootPhiRectangle, "Root-Phi Rectangle"),
5454
new GridModeItem(GridType.Root2Rectangle, "Root-2 Rectangle"),
5555
new GridModeItem(GridType.Root3Rectangle, "Root-3 Rectangle"),
5656
new GridModeItem(GridType.Root4Rectangle, "Root-4 Rectangle"),

Src/ScreenGrid.Models/Grids/GridType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public enum GridType
7878
/// <summary>
7979
/// Root-Phi or Penton (1:√φ)
8080
/// </summary>
81-
// TODO: RootPhiRectangle,
81+
RootPhiRectangle,
8282

8383
/// <summary>
8484
/// Root-2 or Diagon (1:√2)

0 commit comments

Comments
 (0)