@@ -80,8 +80,9 @@ public static Point TransformPoint(
8080 /// <param name="gridType">Selected type of grid</param>
8181 /// <param name="width">Width of output image</param>
8282 /// <param name="height">Height of output image</param>
83+ /// <param name="isRotated">Output grid is rotated (width swapped with height)</param>
8384 /// <returns>List of lines</returns>
84- public static IEnumerable < Line > CreateGrid ( GridType gridType , double width , double height )
85+ public static IEnumerable < Line > CreateGrid ( GridType gridType , double width , double height , bool isRotated )
8586 {
8687 switch ( gridType )
8788 {
@@ -256,7 +257,8 @@ public static IEnumerable<Line> CreateGrid(GridType gridType, double width, doub
256257
257258 if ( gridType == GridType . FibonacciRectanglesZoomed )
258259 {
259- lines = StretchToRectangleWithAspectRatio ( lines , width , height , left , right , top , bottom ) ;
260+ var aspect = ( isRotated ) ? ( height / width ) : ( width / height ) ;
261+ lines = StretchToRectangleWithAspectRatio ( lines , aspect , left , right , top , bottom ) ;
260262 }
261263 else if ( gridType == GridType . FibonacciRectanglesStretched )
262264 {
@@ -341,11 +343,11 @@ public static IEnumerable<Line> CreateGrid(GridType gridType, double width, doub
341343
342344 if ( gridType == GridType . GoldenSpiralZoomed )
343345 {
344- lines = StretchToRectangleWithAspectRatio ( lines , width , height , minX , maxX , minY , maxY ) ;
346+ var aspect = ( isRotated ) ? ( height / width ) : ( width / height ) ;
347+ lines = StretchToRectangleWithAspectRatio ( lines , aspect , minX , maxX , minY , maxY ) ;
345348
346349 // Adding extents lines
347350 var extents = GetExtents ( lines ) ;
348- var aspect = ( width / height ) ;
349351 if ( aspect < RatioConstants . Phi )
350352 {
351353 lines . Add ( new Line ( RatioConstants . Zero , extents . Top , RatioConstants . One , extents . Top ) ) ;
@@ -375,10 +377,8 @@ public static IEnumerable<Line> CreateGrid(GridType gridType, double width, doub
375377 }
376378 }
377379
378- private static List < Line > StretchToRectangleWithAspectRatio ( List < Line > lines , double width , double height , double left , double right , double top , double bottom )
380+ private static List < Line > StretchToRectangleWithAspectRatio ( List < Line > lines , double aspect , double left , double right , double top , double bottom )
379381 {
380- var aspect = ( width / height ) ;
381-
382382 if ( aspect < RatioConstants . Phi )
383383 {
384384 lines = StretchToRectangle ( 1.0 , ( RatioConstants . Phi - 1.0 ) * aspect , lines , left , top , right , bottom ) ;
0 commit comments