home *** CD-ROM | disk | FTP | other *** search
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "DistortCircle"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
-
- ' The center about which to twist.
- Public cx As Single
- Public cy As Single
- Public radius As Single
-
- ' ************************************************
- ' Apply a shape distorting transformation to
- ' the point.
- ' ************************************************
- Sub Distort(x As Single, y As Single)
- Dim r As Single
- Dim newr As Single
- Dim dx As Single
- Dim dy As Single
-
- dx = x - cx
- dy = y - cy
- If dx = 0 And dy = 0 Then Exit Sub
-
- r = Sqr(dx * dx + dy * dy)
- newr = radius * (1 - 1 / (r / radius * 2 + 1))
-
- x = cx + dx / r * newr
- y = cy + dy / r * newr
- End Sub
-