Sharpen the patterns.

Draw the patterns with the intended resolution instead of scaling
afterwards. Scaling leads to unclear patterns.

Also:
Make TilingPattern function for paintType switch case.
Make TilingPattern function for bbox clipping.
Make TilingPattern functions for scaling code.
Make function for determinant calculation.
Increase MAX_PATTERN_SIZE to 4096.
Add matrix multiplication and Singular Value Decomposition functions.