Question: You are going to create a program that draws cool patterns. The user will have three modes to choose from: Rectangle Pattern - A circular
You are going to create a program that draws cool patterns. The user will have three modes to choose from:
Rectangle Pattern A circular pattern created by drawing multiple rectangles
Circle Pattern A circular pattern created by drawing multiple circles
Super Pattern A random selection of some number of Rectangle and Circle Patterns
Coding Notes
taskpy Use the starter file given and only fill in the appropriate areas. Do not modify any code that is there already, only add to it This file will help you with defining the functions in pattern.py
You will need to fill in the input functions, so that depending on what the user selects, you ask them for the necessary information to call the function
You will also need to add code to either clear the screen or play again
Besides these, you should not modify the starter code given
pattern.py You must define the following functions. Include the design for functions with an
setup
Call drawly.start
Set a window title
Set speed to to make life less painful
Use default window sizes do nothing special
reset Erase all of the patterns and start over
Either draw a white rectangle to fill the screen OR
Call redraw without drawing anything before it
drawrectanglepattern
See additional information below
drawcirclepattern
See additional information below
drawsuperpattern
Parameter is a the number of patterns to draw
Use default of
Randomly draw Rectangle and Circle patterns. Each pattern should be based on random values.
Use reasonable random values some can be negative so patterns are drawn on the screen
setrandomcolor
Do not use any parameters
Set drawly to draw in a random color
Use at least colors hint: use random.choice, and create a constant list of colors in the global scope
getdistancepointdistance angle
This returns an x y coordinate as a list. It is the point located at the given distance and angle relative to
You'll use it to draw in the right place
If you give this function an angle from and a distance the offset it will return the correct x and y coordinates of a point that distance away using that angle assuming an origin of
Use this as an offset from the center x and y of your shapes to figure out where to draw them
Use this code:
import math
def getdistancepointdistance angle:
xpos distance math.cosmathradiansangle
ypos distance math.sinmathradiansangle
return xpos, ypos
Make sure to read the rubric to see the additional requirements.
Drawing Rectangle Pattern
The Rectangle Pattern has parts to it
Center position This is the x y center point of the circular pattern that is drawn
Offset This is the distance from the center position to the top left corner of each rectangle. It can be a positive or negative number
Height The height of a rectangle
Width The width of a rectangle
Count The number of rectangles to draw within the degree pattern. They should be evenly spaced around the center.
Rotation The number of degrees each rectangle is rotated in relation to the line from the Center Position to the starting corner of the rectangle. A rotation of would mean the top of the rectangle would be an extension of the line from the center of the pattern to the top left corner. It does not matter which direction your rotation goes, which means you can go either clockwise or counter clockwise for a positive rotation value. Negative values would go the opposite nothing special to do to make that happen
Each individual rectangle should be a new random color. You should use at least different colors.
Hints:
It helps to set this up as a for loop so that you loop from to count number of times.
Remember that the third argument in a range function is the step size, not the count.
Supplying a rotationangle argument to drawly.rectangle will rotate the rectangle a certain number of degrees
rotationpointdrawly.RotationPoint.TOPLEFT in your drawly.rectangle function will make your rectangle rotate around the topleft corner of it
Drawing Circle Pattern
The Circle Pattern has parts to it
Center position This is the x y center point of the circular pattern that is drawn
Offset This is the distance from the center position the closest point of the circle. It can be a positive or negative number Dont do anything special for negative numbers. It'll just work if you get positive numbers working Note that the center point of each circle should be 'radius offset' distance from the Center Position of the pattern.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
