Mondrian Painting

This sketch uses Mondrian as an example to demonstrate the results of what you might call 'square packing' - although instead of packing these images are the result of splitting. The first square is full screen, a random point is generated somewhere in the center of it, then a choice is made whether to split that square horizontally or vertically. Now we have two squares, and from here the process repeats. One of the two squares will always split, the other one will split half the time. A random choice is made to assign blue or red to boxes that are small enough. I deliberately chose to vary the stroke width, even though this diverges from Mondrian's typical style. I'm just fascinated by the effects of deeper recursion and that gets lost unless you shrink the line width.

    // Processing JS:
    // http://processingjs.org/