If you study the code I wrote, you'll learn that it already centers horizontally using the viewport left and width. Centering vertically is done the same way. Creating different shapes is just a matter of playing with the math.
Two ways that come to mind to make irregular shapes is 1. using unique formulas like I did for the one above or 2. predefine the layouts with arrays with 0's and 1's whereby the 1's indicate that a sprite should be created.
But, you're planning on 500 levels which would be a LOT of arrays. What I would look at doing is writing a formula that randomly creates 1/4 of the array which would say, draw the top left quadrant. By reading the array back in different directions, you could draw the other 3 quadrants and they'd be symmetrical like the image you have above. The trick would be to consider the fact that the rows alternate in even and odd numbers of sprites.
But, you have lots of other things to consider. If this is a typical memory match game where you match 2 images you'll have to figure out how to keep the layout to an even number. You'll have to figure out how you're going to display those sprites, how to 'match' them and how to get them to layout with the proper number of each using the same layout you did for the blue ones.