100 Points Please Save As Mondrianart.Py

100 Points Please Save As Mondrianart.Py

Mondrian Art Program

100 Points Please save as MondrianArt.py.

Introduction

Piet Mondrian was a Dutch artist who liked to place rectangles of various shapes and colors on a canvas. Here is one such example. For this assignment, you are going to write a Python program that randomly generates Mondrian-like art.

The user should be asked to enter (1) the number of rectangles that should be drawn, (2) the maximum width of a rectangle in pixels and (3) the maximum height of a rectangle in pixels. The Python program, running in IDLE, should then draw the appropriate number of rectangles where each rectangle is randomly colored, randomly positioned and randomly sized. Below is a drawing that might result if the user requests 200 rectangles with a maximum width of 100 pixels and a maximum height of 100 pixels.

Requirements and Grading

Use the IDLE environment to develop your solution.

  • 20 points - The user is prompted to enter (1) the number of rectangles, (2) the maximum width of a rectangle in pixels and (3) the maximum height of a rectangle in pixels (10 points). The program may assume that the user will enter non-negative integers. However, if the user enters a width or height that is less than 10 pixels, use 10 as the value for that dimension (10 points). Hint – You could use the max function.
  • 20 points - The following items are determined randomly: the x and y coordinates of the upper left corner of the rectangle (5 points), the width and height of the rectangle (5 points) and the color of the rectangle (10 points).
  • 20 points - The correct number of rectangles are drawn (5 points), all rectangles appear at least partially in IDLE's Python Turtle Graphics window (5 points) and a rectangle can appear pretty much anywhere in IDLE's Python Turtle Graphics window (10 points).
  • 10 points - The background color of IDLE's Python Turtle Graphics window is black.
  • 10 points - Two or more user-defined functions are used appropriately. In particular, there should be a function that draws a single rectangle.
  • 10 points - The turtle draws quickly (5 points) and no turtle is visible once the drawing is complete (5 points).
  • 10 points - The Python solution is easy to understand and does not contain unnecessary code. (Remember to put an appropriate comment at the top of the Python solution.)

Helpful Hints

  • Take a look at the random module and the turtle module in Python's online documentation to see what functionality is possible.
  • You can make random colors by creating 3 random numbers from 0 to 255 representing the values for the amount of red, green & blue:

newColor = red, green, blue

  • You will need wn.colormode(255) where wn=turtle.Screen() to use the color.