home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH7 / SRC / DTWIST.CLS < prev    next >
Encoding:
Text File  |  1995-10-25  |  684 b   |  30 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "DistortTwist"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. ' The center about which to twist.
  11. Public cx As Single
  12. Public cy As Single
  13.  
  14. ' ************************************************
  15. ' Apply a shape distorting transformation to
  16. ' the point.
  17. ' ************************************************
  18. Sub Distort(x As Single, y As Single)
  19. Dim r As Single
  20. Dim dx As Single
  21. Dim dy As Single
  22.  
  23.     dx = x - cx
  24.     dy = y - cy
  25.     r = Sqr(dx * dx + dy * dy) / 350 / 3.14
  26.     
  27.     x = cx + dx * Sin(r) - dy * Cos(r)
  28.     y = cy + dx * Cos(r) + dy * Sin(r)
  29. End Sub
  30.