Watch an hourglass print in stars: an inverted pyramid and a pyramid sharing one star, from a single loop over the distance to the middle row.
About this algorithm
The hourglass is the inverted pyramid on top of the pyramid, sharing one star in the middle row. One loop draws both halves by measuring how far each row is from the middle.
Try it right after the diamond. The diamond grows towards the middle row; the hourglass shrinks towards it, so it is the same distance trick read the other way.
The page uses 2n - 1 rows and 2n - 1 columns.
level = |i - (n - 1)|: n - 1 on the first and last rows, 0 on the middle row.
Each row skips n - 1 - level spaces and prints 2 * level + 1 stars, so the wide rows are at the ends and one star sits in the middle.
A 9 by 9 grid. Stars per row: 9, 7, 5, 3, 1, 3, 5, 7, 9, which is 49 stars and 32 spaces in 81 cells.
The diamond uses level = n - 1 - |i - (n - 1)|, which is 0 at the ends and n - 1 in the middle. The hourglass uses |i - (n - 1)| itself, which is the other way round. The space and star formulas are the same on both pages, so swapping one line turns either shape into the other.
If you write the hourglass as two loops, one for the inverted pyramid and one for the pyramid, start the second loop at its second row. Otherwise the single middle star prints twice, which is the usual slip on this shape.
Time: every cell of the (2n - 1) by (2n - 1) grid gets one test, roughly 4n² in total. Space: the level and the star range are a few integers worked out for each row.