Handouts: Graphics Reference

Relevant Example: Optical Illusion

File: number_grid.py

This is a bonus program! It's meant to be a bit difficult.

Write a graphics program that draws a centered, numbered square grid on the screen, like this:


Your program should do this by implementing a function draw_numbered_grid that can take in a dimension and draw a number grid with that many rows and that many columns. Then your main function should call that function. This means that your program should be able to handle different sizes of grids:


Milestones

1) First, try to draw a rectangle the size of the entire number grid in the correct position. For instance, for 5x5 you would try to draw this:


2) Break down your solution into another function that can draw a single square at a given position, displaying a given number. Start by drawing just the red square, and not worrying about the number text within it.


3) Add the number text within each square.