Question: Your task is to write a Python program that uses recursion to generate pseudo-random art in a Mondrian style. Your programs output will be a
Your task is to write a Python program that uses recursion to generate pseudo-random art in a Mondrian style. Your programs output will be a tkinter canvas that contains the image you created. The following general strategy will be used to generate art in a Mondrian style:
If the region is wider than half the initial canvas size and the region is taller than half the initial canvas height:
Use recursion to split the region into 4 smaller regions (a vertical split and a horizontal
split) with both split locations chosen randomly. Else if the region is wider than half the initial canvas size:
Use recursion to split the region into 2 smaller regions using a vertical line with the split
location chosen randomly. Else if the region is taller than half the initial canvas size:
Use recursion to split the region into 2 smaller regions using a horizontal line with the
split location chosen randomly. Else if the region is big enough to split both horizontally and vertically, and both a horizontal and
vertical split are randomly selected: Use recursion to split the region into 4 smaller regions (a vertical split and a horizontal split) with both split locations chosen randomly.
Else if the region is wide enough to split horizontally, and a horizontal split is randomly selected: Use recursion to split the region into 2 smaller regions using a vertical line with the split location chosen randomly.
Else if the region is tall enough to split vertically, a vertical split is randomly selected: Use recursion to split the region into 2 smaller regions using a horizontal line with the split location chosen randomly.
Else: Fill the current region (randomly, either white or colored, and if colored, with a random determination of red, blue or yellow).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
