generate horizontal linesy random randint(min_y_increasemax_y_increasewhile height min_y_increasenumberofsegmentstodelete + for in range(width)canvas[(xy)black +random randint(min_y_increasemax_y_increasenumberofrectanglestopaint numberofsegmentstodelete numberofsegmentstodelete int(numberofsegmentstodelete randomly select points and try to remove them for in range(numberofsegmentstodelete)while truekeep selecting segments to try to delete get random start point on an existing segmentstartx random randint( width starty random randint( height if canvas[(startxstarty)=whitecontinue find out if we're on vertical or horizontal segmentif (canvas[(startx starty)=white and canvas[(startx starty)=white)orientation 'verticalelif (canvas[(startxstarty )=white and canvas[(startxstarty )=white)orientation 'horizontalelsethe start point is on an intersectionso get new random start pointcontinue pointstodelete [(startxstarty)candeletesegment true if orientation ='vertical'go up one path from the start pointand see if we can remove this segmentfor changey in (- ) starty while height +changey if (canvas[(startx )=black and canvas[(startx )=black)we've found four-way intersection break elif ((canvas[(startx )=white and canvas[(startx )=blackor (canvas[(startx )=black and canvas[(startx )=white))we've found -intersectionwe can' delete this segmentcandeletesegment false break mondrian art generator