190 likes | 271 Views
5. Graphics and Procedures. Programming Right from the Start with Visual Basic .NET 1/e. Objectives. Learn the Visual Logic graphics commands and how they work Appreciate the concept of structured design Know the process for creating procedures. Objectives (cont.).
E N D
5 Graphics andProcedures Programming Right from the Start with Visual Basic .NET 1/e
Objectives • Learn the Visual Logic graphics commands and how they work • Appreciate the concept of structured design • Know the process for creating procedures
Objectives (cont.) • Understand the role of procedure arguments • Realize the difference between formal arguments and actual arguments • Develop and evaluate solutions that utilize graphics and procedures
Visual Logic graphics are a variation on Logo Programming Language, which has been used in educational settings for over three decades. 5-1 Graphics
Forward and Turn Right • The Forward command moves the pen a specified number of units. • The Turn Right command rotates the drawing direction a specified number of degrees.
Using Loops • Two Patterns Emerge… • Repetition of the commands Forward and Turn Right • The degrees the drawing direction must turn right are different for each shape and are based on the number of sides in the shape
5-2 Working with Color • The pen draws with black ink and is 1 unit in width. • Visual Logic provides commands for changing the pen’s color and width.
Set Color and Pen Width • The Set Color command allows the developer to select any color from the standard color dialog box. • The Pen Width command changes the thickness of the drawing pen.
Color Forward • The Color Forward command moves the pen through the three base colors of red, green, and blue. • The Color Forward command typically occurs inside a loop.
5-3 Structured DesignUsing Procedures • Structured design means a problem is broken into smaller pieces, each of which is solved individually. • A procedure is a series of instructions that are grouped together and treated as a single unit.
5-4 Procedures with Arguments • An argument (or parameter) is a piece of information that is communicated between the calling code and the procedure. • The argument is referred to as an actual argument at the time of the call and as a formal argument in the called procedure.
5-5 Recursion • A recursive procedure is a procedure that calls itself. • To prevent infinite recursion, a recursive procedure typically first performs a test on one of its arguments to check for a base case.
Chapter Summary • Visual Logic graphics include commands, such as Forward and Right, that move a virtual pen across the screen. • Procedures allow code to be written once and called many times. • An actual argument is a value or reference passed from the calling code to a procedure.
5 Graphics andProcedures Programming Right from the Start with Visual Basic .NET 1/e