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

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "DistortCircle"
  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. Public radius As Single
  14.  
  15. ' ************************************************
  16. ' Apply a shape distorting transformation to
  17. ' the point.
  18. ' ************************************************
  19. Sub Distort(x As Single, y As Single)
  20. Dim r As Single
  21. Dim newr As Single
  22. Dim dx As Single
  23. Dim dy As Single
  24.  
  25.     dx = x - cx
  26.     dy = y - cy
  27.     If dx = 0 And dy = 0 Then Exit Sub
  28.     
  29.     r = Sqr(dx * dx + dy * dy)
  30.     newr = radius * (1 - 1 / (r / radius * 2 + 1))
  31.     
  32.     x = cx + dx / r * newr
  33.     y = cy + dy / r * newr
  34. End Sub
  35.