import turtle import random def random_color():   return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)) def draw_section(x, y, size, points, fill_color):   turtle.penup()   turtle.goto(x, y)   turtle.pendown()   turtle.fillcolor(fill_color)   turtle.begin_fill()   for point in points:     turtle.goto(x + point[0] * size, y + point[1] * size)   turtle.end_fill() def draw_cell(x, y, size):   colors = [random_color() for _ in range(4)]   draw_section(x, y, size, [(0, 0), (0.5, -0.4), (0.4, -0.7), (1, -0.2), (1, 0)], colors[0])   draw_section(x, y, size, [(0, 0), (0.5, -0.4), (0.4, -0.7), (0, -0.9)], colors[1])   draw_section(x, y, size, [(0, 0), (1, 0), (1, -0.2), (0.4, -0.7), (0, -0.9), (0.65, -0.85), (1, -1), (1, -0.2), (1, 0), (0, 0)], colors[2])   draw_section(x, y, size, [(0, -0.9), (0.65, -0.85), (1, -1), (0, -1), (0, -0.9)], colors[3]) def draw_grid(n, cell_size, pen_color):   for i in range(n):     for j in range(n):       x = j * cell_size - n * cell_size / 2       y = n * cell_size / 2 - i * cell_size       turtle.color(pen_color)       turtle.up()       turtle.goto(x, y)       turtle.down()       turtle.forward(cell_size)       turtle.right(90)       turtle.forward(cell_size)       turtle.right(90)       turtle.forward(cell_size)       turtle.right(90)       turtle.forward(cell_size)       turtle.right(90)       draw_cell(x, y, cell_size) def main():   turtle.tracer(False)   turtle.colormode(255)   n = int(input("Grid size (n): "))   pen_color = "black"   size_for_canvas = 500   cell_size = size_for_canvas / n   s = turtle.Screen()   s.setup(width=size_for_canvas + 10, height=size_for_canvas + 10)   s.screensize(size_for_canvas, size_for_canvas)   draw_grid(n, cell_size, pen_color)   turtle.tracer(True) #   turtle.mainloop() main() used this code by doing these suggestion  For this final milestone, you will be creating your pattern and applying more of your own changes to each cell. The design is entirely up to you, but your design should still be complex as the drawing from milestone 4 & 5. It should not feel minimal effort, i.e., only having a simple polygon or splitting the cell into 3 equal rectangles. Once you have your pattern, generate a grid with the pattern. Suggestions on what you can try applying to each cell: Rotating each cell Adding random shapes on top of the cell Changing the size of each cell By the end of this milestone, your program should be able to generate an n by n grid where each cell is has a pat

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

import turtle
import random

def random_color():
  return (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))


def draw_section(x, y, size, points, fill_color):
  turtle.penup()
  turtle.goto(x, y)
  turtle.pendown()

  turtle.fillcolor(fill_color)
  turtle.begin_fill()

  for point in points:
    turtle.goto(x + point[0] * size, y + point[1] * size)

  turtle.end_fill()


def draw_cell(x, y, size):
  colors = [random_color() for _ in range(4)]

  draw_section(x, y, size, [(0, 0), (0.5, -0.4), (0.4, -0.7), (1, -0.2), (1, 0)], colors[0])
  draw_section(x, y, size, [(0, 0), (0.5, -0.4), (0.4, -0.7), (0, -0.9)], colors[1])
  draw_section(x, y, size, [(0, 0), (1, 0), (1, -0.2), (0.4, -0.7), (0, -0.9), (0.65, -0.85), (1, -1), (1, -0.2), (1, 0), (0, 0)], colors[2])
  draw_section(x, y, size, [(0, -0.9), (0.65, -0.85), (1, -1), (0, -1), (0, -0.9)], colors[3])


def draw_grid(n, cell_size, pen_color):
  for i in range(n):
    for j in range(n):
      x = j * cell_size - n * cell_size / 2
      y = n * cell_size / 2 - i * cell_size
      turtle.color(pen_color)
      turtle.up()
      turtle.goto(x, y)
      turtle.down()
      turtle.forward(cell_size)
      turtle.right(90)
      turtle.forward(cell_size)
      turtle.right(90)
      turtle.forward(cell_size)
      turtle.right(90)
      turtle.forward(cell_size)
      turtle.right(90)
      draw_cell(x, y, cell_size)

def main():
  turtle.tracer(False)
  turtle.colormode(255)
  n = int(input("Grid size (n): "))
  pen_color = "black"

  size_for_canvas = 500
  cell_size = size_for_canvas / n

  s = turtle.Screen()
  s.setup(width=size_for_canvas + 10, height=size_for_canvas + 10)
  s.screensize(size_for_canvas, size_for_canvas)

  draw_grid(n, cell_size, pen_color)

  turtle.tracer(True)
#   turtle.mainloop()
main()
used this code by doing these suggestion 

For this final milestone, you will be creating your pattern and applying more of your own changes to each cell. The design is entirely up to you, but your design should still be complex as the drawing from milestone 4 & 5. It should not feel minimal effort, i.e., only having a simple polygon or splitting the cell into 3 equal rectangles.

Once you have your pattern, generate a grid with the pattern.

Suggestions on what you can try applying to each cell:

  • Rotating each cell
  • Adding random shapes on top of the cell
  • Changing the size of each cell

By the end of this milestone, your program should be able to generate an by grid where each cell is has a pattern design and changes of your own. 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Concept of Threads
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.
Similar questions
  • SEE MORE QUESTIONS
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