from cs1graphics import * numLevels = 7 # number of levels bricksPerLevel = 10 unitSize = 12 # the height of one level ratio = 3 totalWidth = 3 * unitSize * (bricksPerLevel+1) totalHeight = (numLevels+2) * unitSize paper = Canvas(totalWidth, totalHeight) # create levels from top to bottom paper.setTitle('Another brick in the wall') for level in range(numLevels): centerY = (level + 1.5) * unitSize leftmostX = unitSize * ratio for b in range(bricksPerLevel): brick = Rectangle(ratio*unitSize, unitSize) brick.setFillColor('firebrick') brick.move(leftmostX+b*ratio*unitSize, centerY) paper.add(brick) paper.saveToFile('bricks.eps')