Recursion is not just for fractals...
Mondrian did not use a computer, but we can use recursion to model his paintings and create similar images:
and use a large pen size, as we did for this project. You will probably want to change that setting back for other projects.
Mondrian is already set up.rectangle block. Use a line of color with a pen size the width of the rectangle to paint the inside and then create the black border. Maintain state transparency.
rectangle block already contains two custom blocks for you to use. Look inside these two custom blocks to see how they work.
rectangle set up correctly. Each time, you should get a big rectangle with one of the five colors inside and a black border, like this:
Then, program the code for the recursive case. The Mondrian block already contains some structure. Your job is to figure out what inputs it will need based on how the script should work.
Mondrian subdivides the space it has into two rectangles (which will further subdivide if more levels are required). For example, in level 2, Mondrian will randomly divide the area specified by its width and height inputs in two pieces, and draw a rectangle in each piece. For level 3, Mondrian uses a level-2 Mondrian to subdivide the two smaller rectangles (for a total of four filled-in rectangles). Level 4 will subdivide again, creating eight rectangles, and so on.
Mondrian working, it should produce pictures like this: