take your time but could you have in python please

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

take your time but could you have in python please

Write a program that draws a square fractal. Fractals are images that keep repeating their own
image in ever-smaller versions. There exist numerous fractals and some fractals rely on computation
of advanced mathematics. All fractals have a recursive quality and provide an ideal platform for
practicing recursive concepts. This lab assignment is easiest to explain by first looking at the result of
the 50-point execution below. You will note that from the four corners of the center rectangle, smaller
rectangles are drawn and each rectangle in turn continues to draw three smaller rectangles until the
rectangle is the size of one pixel.
Recursive Rectangles
Your given class Recursive Graphic that has several instance variables. These variable generally get
the graphic started by finding the top left corner and size of the center rectangle
Method drawRectangles gets the ball rolling for all the draw methods. The drawCenterRectangle
method will draw the rectangle in the center of the window. You will need to make new methods that
will draw rectangles on each corner of each new rectangle drawn. Each new rectangle is exactly half
the width and heigh of the previous rectangle. You should keep drawing rectangles while the width of
the rectangle is greater than 1. My suggestion would be to create 4 methods that can draw a new
square on the 4 corners of the center square.
Transcribed Image Text:Write a program that draws a square fractal. Fractals are images that keep repeating their own image in ever-smaller versions. There exist numerous fractals and some fractals rely on computation of advanced mathematics. All fractals have a recursive quality and provide an ideal platform for practicing recursive concepts. This lab assignment is easiest to explain by first looking at the result of the 50-point execution below. You will note that from the four corners of the center rectangle, smaller rectangles are drawn and each rectangle in turn continues to draw three smaller rectangles until the rectangle is the size of one pixel. Recursive Rectangles Your given class Recursive Graphic that has several instance variables. These variable generally get the graphic started by finding the top left corner and size of the center rectangle Method drawRectangles gets the ball rolling for all the draw methods. The drawCenterRectangle method will draw the rectangle in the center of the window. You will need to make new methods that will draw rectangles on each corner of each new rectangle drawn. Each new rectangle is exactly half the width and heigh of the previous rectangle. You should keep drawing rectangles while the width of the rectangle is greater than 1. My suggestion would be to create 4 methods that can draw a new square on the 4 corners of the center square.
from graphics import *
class RecursiveGraphic (object):
de f ____init__(self, win: GraphWin):
self.startWidth = 250
if
self.startHeight = 200
self.tlx = win.getWidth() // 2 - self.startWidth // 2
self.tly = win.getHeight () // 2 - self.startHeight // 2
def drawRectangles (self, win) :
self.drawCenterRectangle
(win)
# Make the initial call to your method (s) here
def drawCenterRectangle (self, win) :
rect = Rectangle (Point (self.tlx, self.tly), Point (self.tlx + self.startWidth, self.tly + self.startHeight))
rect. setFill ("Black")
rect.draw (win)
# Create your recursive method (s) here
def main ():
win = GraphWin ("Recursive Rectangles", 1000, 650)
rg
RecursiveGraphic (win)
rg.drawRectangles (win)
win.getMouse ()
win.close()
name == '_____main____':
main ()
Transcribed Image Text:from graphics import * class RecursiveGraphic (object): de f ____init__(self, win: GraphWin): self.startWidth = 250 if self.startHeight = 200 self.tlx = win.getWidth() // 2 - self.startWidth // 2 self.tly = win.getHeight () // 2 - self.startHeight // 2 def drawRectangles (self, win) : self.drawCenterRectangle (win) # Make the initial call to your method (s) here def drawCenterRectangle (self, win) : rect = Rectangle (Point (self.tlx, self.tly), Point (self.tlx + self.startWidth, self.tly + self.startHeight)) rect. setFill ("Black") rect.draw (win) # Create your recursive method (s) here def main (): win = GraphWin ("Recursive Rectangles", 1000, 650) rg RecursiveGraphic (win) rg.drawRectangles (win) win.getMouse () win.close() name == '_____main____': main ()
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education