Simple Matriks Algorithm with pattern like this
Case 1 : show you how to build pattern from left bottom -> top -> right -> bottom ->left like clockwise
Case 2 : show you how to build pattern like below (Sorry i can't explain the pattern)
and Case 3. just try and see the result... :D
just it. hope this is useful for u.
Thanks