Rotate: Visual Basic Version


'*****************************************************************************
'                                                                            *
'  Rotate.frm                                                                *
'                                                                            *
'  This program demonstrates the Fastgraph for Windows 256-color bitmap      *
'  rotation functions.                                                       *
'                                                                            *
'*****************************************************************************
Const vbWidth = 320
Const vbHeight = 240
Dim hPal As Long
Dim hVB As Long
Dim cxClient As Long, cyClient As Long
Dim Bird(40 * 20) As Byte
Dim RotatedBird(40 * 20 * 4) As Byte
Private Sub Form_Activate()
   Call fg_realize(hPal)
   Refresh
End Sub
Private Sub Form_Load()
   Dim RotatedWidth As Long, RotatedHeight As Long
   Dim Angle As Long
   ScaleMode = 3
   Call fg_setdc(hDC)
   hPal = fg_defpal()
   Call fg_realize(hPal)
   Call fg_vbinit
   hVB = fg_vballoc(vbWidth, vbHeight)
   Call fg_vbopen(hVB)
   Call fg_vbcolors
   Call fg_setcolor(20)
   Call fg_fillpage
   Call LoadBird
   ' display the original (unrotated) bird bitmap
   Call fg_move(140, 80)
   Call fg_drwimage(Bird(0), 40, 20)
   ' display the bitmap rotated by 30, 60, 90, 120, 150, and 180 degrees
   Call fg_move(10, 140)
   For Angle = 30 To 180 Step 30
      Call fg_rotsize(40, 20, Angle * 10, RotatedWidth, RotatedHeight)
      Call fg_rotate(Bird(0), RotatedBird(0), 40, 20, Angle * 10)
      Call fg_drwimage(RotatedBird(0), RotatedWidth, RotatedHeight)
      Call fg_moverel(RotatedWidth + 10, 0)
   Next Angle
End Sub
Private Sub Form_Paint()
   Call fg_vbscale(0, vbWidth - 1, 0, vbHeight - 1, 0, cxClient - 1, 0, cyClient - 1)
End Sub
Private Sub Form_Resize()
   cxClient = ScaleWidth
   cyClient = ScaleHeight
   Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
   Call fg_vbclose
   Call fg_vbfree(hVB)
   Call fg_vbfin
End Sub
Private Sub LoadBird()
   Dim I As Long
   Open App.Path & "\Bird256.dat" For Input Access Read As #1
   For I = 0 To 40 * 20 - 1
      Input #1, Bird(I)
   Next I
   Close #1
End Sub

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.