#Find how many times the patterns will fit in the X and Y directions #Set the current location to be the start point
loop up to the number of times the pattern will fit on the canvas:
#run the pattern function to place the pattern at the current location
Update the current location based on these rules: 1. If I am in the first row keep working along the X direction until I reach the edge 2. Then work along the Y direction until the next edge is reached 3. Now work along the x direction in reverse 4. When the x location is the same as the start start back along the Y 5. Once the Y location is one pattern width more than the start location, reduce the size of the canvas and set the new start point to be +1 pattern with in X and Y
Rule 5 causes the result to reset to rule 1.
There are 626 possible 2x2 patterns to choose from which you could apply to the frame using only the two types of tiles supplied. Only those around the outside edge of the render with two or more circles can't be applied as a repeating pattern across the whole frame.