CSCI 220 Programming With Visual Basic
Lecture 10: More Animation

                              
Imageboxes vs picture boxes
  Images
     Automatically stretch to fit picture
     Have no inherent background
     Take far less memory
     Can do less
  Picture boxes
     Basically 'mini-forms'
     Can be printed on,
     Has graphic methods
     Can 'hold' other controls
     Very powerful, but take much memory
  
Types of graphics:
  Bitmaps
     Usually end in .BMP
     File contains pixel - by - pixes representation of
     drawing
     Usually copied in from paintbrush
     Easy to do
     Will distort when resized
     Cannot have invisible background
  Windows MetaFiles
     End in WMF
     File contains CODE used by Windows to draw image
     Little distortion when resized
     Have no background
     Created in programs like windows draw (From within Word
     or other programs)
     Similar to Macintosh drawing schemes.
  Icons
     Special format
     Best drawn with Icon design program
     Icon Works (VB sample program)
     Invisible background
     Useful for animation, games
     Resizing is clumsy

Ways to get graphics
  Copy and paste
     Probably easiest
     Graphic is stored in .frx file.  Original need not be
     present
  Picture property - design time
     Loads picture into .Frx
     Picture must have already been created and saved on
     disk
     Uses lots of disk space.
  Picture property - run time
     Uses LoadPicture function
     Syntax:  ControlName.Picture = LoadPicture
     (PictureFileName)
     ControlName is the name of a control that has the
     picture property
     PictureFileName is the complete pathname of a graphic
     file
  Drawing Methods
     Usable only on Form, Picture Box, and Printer
     Derived from traditional languages
     Tedious, but allow for interactive drawing
     Usually accessed in MouseDown and MouseMove Functions
     Sample Methods:
       Circle (X,Y),Radius
       Line (X1,Y1)-(X2,Y2)
       Line (X1,Y1)-(X2,Y2),B   'Draws a rectangle
       Point (X,Y)              'Draws a dot
     Example
       Picture1.Circle(100,100),50
       Draws a circle at 100,100 of radius 50
     Use online help for more info
  Line and Shape controls
     Usable only at design - time
     helpful for creating backgrounds
     
Animation Concepts
  Moving an image
     Use Move method or change Left and Top properties of
     image box
     Use image box with icon or WMF to make image appear to
     float above background
     Put appropriate picture in image
     Compare left and top property of image to boundaries of
     form
       Top of form: 0    Bottom of form: Form.Height
       Left of form: 0     Right of form:  Form.Width
     
  Flipping through image
     Put images in control array
     Use timer to flip through pictures
     Put Pictures in image box
     Use static variable to control which image is being
     shown
     Use movement commands as needed
  
Other Concepts
  Static variable declaration
     Use as Dim statement in procedures only
     Works just like Dim, but variable retains value when
     procedure is re-called
     (with Dim, the variable is re-initialized each time a
     sub runs)
  Foreground, background placement of graphic images
     Use Move to foreground, move to background commands on
     Edit menu
     Look up Zorder command for more information
  Copying any Windows screen-
    Get the image you want (Netscape or other program)
    Press the Print Screen Key
    ENTIRE screen will be copied to buffer
    Go to paintbrush
    Maximize paintbrush
    From View menu, choose Zoom out
    From Edit, choose Paste
    From Edit, choose Paste again.  (Really!  I don't know why.)
    Now choose the select tool to grab the portion of the image you want
    Copy that image to the clipboard
    Paste into your image box or whatever

Your Project - Graphics and animation

  This one's up to you.  Use at least two types of graphics
  images discussed above to create some type of animation.
  The animation can be anything that uses the techniques
  above.  Possible examples:
     A ball that bounces off the edges of the form
     An image that moves under user control
     An image that moves under timer control
     An image that responds graphically to user input (One
     button smiles, another frowns, etc)
Return to the Syllabus