def test_howto_example_drawing_basics(self): """tests the first canvas example from howto""" test_image = get_image("canvas_1.png") o = get_mock_output() c = Canvas(o, name=c_name) c.point((1, 2)) c.point( ( (2, 1), (2, 3), (3, 4) ) ) c.display() # Shouldn't throw an exception assert(imgs_are_equal(c.get_image(), test_image))
def draw_field(): c = Canvas(o) c.rectangle((0, 0, width-1, height-1)) c.point(snake) if not(applex and appley): create_apple() if level == 1: # We draw the apple c.point([(applex, appley-1), # the leaf (applex-1, appley),(applex, appley),(applex+1, appley), # the top half (applex-1, appley+1),(applex, appley+1),(applex+1, appley+1)]) # the lower half else: c.point((applex, appley)) c.display() # Display the canvas on the screen