Lab 8
comp 125-609, Goldwasser
Tuesday, October 26, 1999

Purpose: Using Graphics in Picture Boxes
In today's lab, we will draw some pictures using the graphics methods available in a picture box. First, we will lead you step by step through the creation of a picture of a truck. Secondly, you will design a picture of a house on your own.
Truck

To begin, place a LARGE picture box (picOut) and a command button (cmdShow) on the form. All the code will be placed under the cmdShow_Click:

Everything described below should be written in code NOT in the properties window.

  • Please create scale which ranges from 0 to 100 horizontally (left to right) and 0 to 100 vertically (bottom to top) in the Picture Box. Do this carefully! If this step is wrong, the whole picture will look even funnier than my rendition of it.

  • Cargo Carrier: Draw a solid, red rectangle from one corner (45,30) to the opposite corner(90,70). Run the program. If you do NOT see a RED SOLID RECTANGLE correct it now.

  • Cab: Draw an open black rectangle from (28,30) to (45,50). Run the program. If you do NOT see the outline of a black cab in front of the solid red cargo carrier, make necessary corrections.

  • Black tires with interesting blue hubcaps: IN CODE (not the properties window), set the FillStyle property for the picture box to 7 (how can you determine what the different choices for FillStyle are?). IN CODE, set the FillColor property for the picturebox to blue. Draw 2 circles-one will be centered at (36, 26); the other at (82,26). Both have a radius of 4. Run the program. Make sure that you have 2 black wheels in the right place with blue cross-hatched hubcaps. Make any necessary corrections.

  • Headlight beams: IN CODE, set the ForeColor property for the picturebox to yellow. IN CODE, set the DrawWidth property for the picturebox to 5. Draw a line from points (28, 32) to (20,28) and another from (28,35) to (20,39). Run the program. Make sure that you have 2 thick yellow lines slanting outward. Make any necessary corrections.

  • Writing on the side of the truck: IN CODE set the ForeColor property for the picturebox to white. Set the CurrentX property for the picturebox to 50. Set the CurrentY property to 55. Use picout.Print to write something descriptive on the truck. Run program. Make sure there is white writing on the side of the red cargo carrier.

  • Aerodynamic wind guard: IN CODE set the FillStyle to 0 and the FillColor to black. create a variable twopi As Double and set its value with twopi = 8*Atn(1). Draw a solid black quarter of a circle, with center (40,50), radius 12, starting the pie slice at -twopi/4 and ending at -twopi/2. Run the program. If you do NOT see the new aerodynamic piece sitting on top of the cab, make necessary corrections.


  • House

    Save your first program somewhere and start a second program from scratch. Use these techniques to design a house. Be as detailed and creative as time allows. Landscaping is optional.


    This lab is due before leaving class today. When you have completed the program, please call me over to your computer to run your program.