# Lab 2: Draw a Picture¶

Your assignment: Draw a pretty picture. The goal of this lab is to get practice using functions to draw, and introduce computer graphics.

## Requirements¶

To get full credit:

• Use the same project and repository that you used for Lab 01. If you forked your repository from mine, you should already have a folder for lab 2. Use that folder, and the lab_02.py file inside. Otherwise create one.
• You must use multiple colors.
• You must have a coherent picture. I am not interested in abstract art with random shapes.
• You must use multiple types of graphic functions (e.g. circles, rectangles, lines, etc.)
• Use blank lines in the code to break up sections. For example, when drawing a tree, put a blank line ahead of, and after.
• Use comments effectively. For example, when drawing a tree, put a comment at the start of those drawing commands that says # Draw a tree. Remember to put one space after the # sign.
• Put spaces after commas for proper “style.”

## Tips¶

To select new colors use:

http://www.colorpicker.com/

Copy the values for Red, Green, and Blue. Do not worry about colors for hue, Saturation, or Brilliance.

Please use comments and blank lines to make it easy to follow your program. If you have 5 lines that draw a robot, group them together with blank lines above and below. Then add a comment at the top telling the reader what you are drawing.

Keep in mind the order of code. Shapes drawn first will be at the “back.” Shapes drawn later will be drawn on top of the other shapes.

Looking for ideas? At the page below, each time you refresh the page I show various images created by students from prior years:

Also, remember you can look up the available commands, called the “API” at:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 """ This is a sample program to show how to draw using the Python programming language and the Arcade library. """ # Import the "arcade" library import arcade # Open up a window. # From the "arcade" library, use a function called "open_window" # Set the window title to "Drawing Example" # Set the and dimensions (width and height) arcade.open_window(800, 600, "Drawing Example") # Set the background color arcade.set_background_color(arcade.color.AIR_SUPERIORITY_BLUE) # Get ready to draw arcade.start_render() # Draw the grass arcade.draw_lrtb_rectangle_filled(0, 800, 200, 0, arcade.color.BITTER_LIME) # --- Draw the barn --- # Barn cement base arcade.draw_lrtb_rectangle_filled(30, 350, 210, 170, arcade.color.BISQUE) # Bottom half arcade.draw_lrtb_rectangle_filled(30, 350, 350, 210, arcade.color.BROWN) # Left-bottom window arcade.draw_rectangle_filled(70, 260, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(70, 260, 20, 30, arcade.color.BLACK) # Right-bottom window arcade.draw_rectangle_filled(310, 260, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(310, 260, 20, 30, arcade.color.BLACK) # Barn door arcade.draw_rectangle_filled(190, 230, 100, 100, arcade.color.BLACK_BEAN) # Rail above the door arcade.draw_rectangle_filled(190, 280, 180, 5, arcade.color.BONE) # Draw second level of barn arcade.draw_polygon_filled([[20, 350], [100, 470], [280, 470], [360, 340]], arcade.color.BROWN) # Draw loft of barn arcade.draw_triangle_filled(100, 470, 280, 470, 190, 500, arcade.color.BROWN) # Left-top window arcade.draw_rectangle_filled(130, 440, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(130, 440, 20, 30, arcade.color.BLACK) # Right-top window arcade.draw_rectangle_filled(250, 440, 30, 40, arcade.color.BONE) arcade.draw_rectangle_filled(250, 440, 20, 30, arcade.color.BLACK) # Draw 2nd level door arcade.draw_rectangle_outline(190, 310, 30, 60, arcade.color.BONE, 5) # --- Draw the tractor --- # Draw the engine arcade.draw_rectangle_filled(600, 120, 140, 70, arcade.color.GRAY) arcade.draw_rectangle_filled(590, 105, 90, 40, arcade.color.BLACK) # Draw the smoke stack arcade.draw_rectangle_filled(580, 175, 10, 40, arcade.color.BLACK) # Back wheel arcade.draw_circle_filled(490, 110, 50, arcade.color.BLACK) arcade.draw_circle_filled(490, 110, 45, arcade.color.BLACK_OLIVE) arcade.draw_circle_filled(490, 110, 35, arcade.color.OLD_LACE) arcade.draw_circle_filled(490, 110, 10, arcade.color.RED) # Front wheel arcade.draw_circle_filled(650, 90, 30, arcade.color.BLACK) arcade.draw_circle_filled(650, 90, 25, arcade.color.BLACK_OLIVE) arcade.draw_circle_filled(650, 90, 18, arcade.color.OLD_LACE) arcade.draw_circle_filled(650, 90, 5, arcade.color.RED) # --- Finish drawing --- arcade.finish_render() # Keep the window up until someone closes it. arcade.run()