Question
(Jython Code) Currently, the function only allows the pattern to be added on to empty picture objects of a fixed size. The end result is
(Jython Code) Currently, the function only allows the pattern to be added on to empty picture objects of a fixed size. The end result is also shown on the screen and cannot be used outside of the function. The function is less reusable/general due these reasons. Your task is to overcome the above limitations by re-writing this function in a more general and reusable form. Your new code must meet the following requirements:
1. The function must take the width and height of the picture object to be created as its parameters and draw the pattern relative to these values. It must not take any other parameters or any other inputs.
2. Assume that only valid parameter values will be passed in to the function. You must not validate any values. The logic of the pattern must be valid on any (valid) combination of parameter values.
3. The picture must not be displayed.
def makePattern picture-makeEmptyPicture (600,400) # addRect usage: addRect (picture,startx,starti, rectWidth, rectHeight) addRect (picture, 0,0,600, 400) addRect (picture, 150,100, 300,200) addRect (picture, 225,150,150,100) repaint (picture)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started