private void DrawPhiRectanglesOnGraphics(Graphics gr, List <PointF> points, double x, double y, double wid, double hgt, RectOrientations orientation) { if ((wid < 1) || (hgt < 1)) { return; } RectangleF rect; switch (orientation) { case RectOrientations.RemoveLeft: rect = new RectangleF( (float)x, (float)y, (float)(2 * hgt), (float)(2 * hgt)); break; case RectOrientations.RemoveTop: rect = new RectangleF( (float)(x - wid), (float)y, (float)(2 * wid), (float)(2 * wid)); break; case RectOrientations.RemoveRight: rect = new RectangleF( (float)(x + wid - 2 * hgt), (float)(y - hgt), (float)(2 * hgt), (float)(2 * hgt)); break; case RectOrientations.RemoveBottom: rect = new RectangleF((float)x, (float)(y + hgt - 2 * wid), (float)(2 * wid), (float)(2 * wid)); break; } // Recursively draw the next rectangle. switch (orientation) { case RectOrientations.RemoveLeft: points.Add(new PointF((float)x, (float)(y + hgt))); x += hgt; wid -= hgt; orientation = RectOrientations.RemoveTop; break; case RectOrientations.RemoveTop: points.Add(new PointF((float)x, (float)y)); y += wid; hgt -= wid; orientation = RectOrientations.RemoveRight; break; case RectOrientations.RemoveRight: points.Add(new PointF((float)(x + wid), (float)y)); wid -= hgt; orientation = RectOrientations.RemoveBottom; break; case RectOrientations.RemoveBottom: points.Add(new PointF((float)(x + wid), (float)(y + hgt))); hgt -= wid; orientation = RectOrientations.RemoveLeft; break; } DrawPhiRectanglesOnGraphics(gr, points, x, y, wid, hgt, orientation); }
private void DrawPhiRectanglesOnGraphics(List<PointF> points, double x, double y, double wid, double hgt, RectOrientations orientation ) { if ( ( wid < 1 ) || ( hgt < 1 ) ) return; switch ( orientation ) { case RectOrientations.RemoveLeft: new RectangleF( ( float )x, ( float )y, ( float )( 2 * hgt ), ( float )( 2 * hgt ) ); break; case RectOrientations.RemoveTop: new RectangleF( ( float )( x - wid ), ( float )y, ( float )( 2 * wid ), ( float )( 2 * wid ) ); break; case RectOrientations.RemoveRight: new RectangleF( ( float )( x + wid - 2 * hgt ), ( float )( y - hgt ), ( float )( 2 * hgt ), ( float )( 2 * hgt ) ); break; case RectOrientations.RemoveBottom: new RectangleF( ( float )x, ( float )( y + hgt - 2 * wid ), ( float )( 2 * wid ), ( float )( 2 * wid ) ); break; } // Recursively draw the next rectangle. switch ( orientation ) { case RectOrientations.RemoveLeft: points.Add( new PointF( ( float )x, ( float )( y + hgt ) ) ); x += hgt; wid -= hgt; orientation = RectOrientations.RemoveTop; break; case RectOrientations.RemoveTop: points.Add( new PointF( ( float )x, ( float )y ) ); y += wid; hgt -= wid; orientation = RectOrientations.RemoveRight; break; case RectOrientations.RemoveRight: points.Add( new PointF( ( float )( x + wid ), ( float )y ) ); wid -= hgt; orientation = RectOrientations.RemoveBottom; break; case RectOrientations.RemoveBottom: points.Add( new PointF( ( float )( x + wid ), ( float )( y + hgt ) ) ); hgt -= wid; orientation = RectOrientations.RemoveLeft; break; } DrawPhiRectanglesOnGraphics(points, x, y, wid, hgt, orientation ); }