Watch a heart print row by row in stars: two lobes on the first row, then a condition on the distance from the middle narrows each row to a point.
About this algorithm
The heart is a picture rather than a formula you grow with n: nine columns and seven rows, with two lobes on top and rows that narrow to a point. One condition on each cell draws it, the same way the classic patterns are drawn.
Try the heart after the pyramid and the diamond. It uses their idea of measuring the distance from the middle column, and adds a special first row for the two lobes. It is a good check that you can turn any picture into a condition on i and j.
The heart is 7 rows by 9 columns at every size: the slider does not change it.
On row 0 a cell is a star when j % 4 is not 0, so columns 0, 4 and 8 stay empty and two lobes of three stars are left.
On every later row a cell is a star when |j - 4| <= 6 - i. Rows 1 and 2 are full, and each row after loses one star on each side.
Stars per row: 6, 9, 9, 7, 5, 3, 1, which is 40 stars and 23 spaces in 63 cells. The last row prints only column 4: the point.
Every row after the first follows one rule, the distance from the middle column. The lobes do not: they need a gap in the middle and at both ends, which is why row 0 has its own test. Most picture patterns work this way, a general rule plus one or two rows handled on their own. Writing the special rows first and the general rule second keeps the condition short and easy to check.
Many tutorials draw a bigger heart from two circles and a triangle, testing x² + y² against a radius for each lobe. That draws a rounder outline but needs floating-point tests. This page keeps every test to whole numbers on a 9 column grid, so you can check each row by counting.
Time: every one of the 63 cells gets one test. Space: the test needs only i and j.