Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitlePlace non-rotated letters along an elliptical path
Keywordstext, ellipse, path
CategoriesGraphics
 
Use Sin and Cos to calculate the positions of the text along the path. Set the current position there and use Print to display the text.
 
Private Sub Form_Load()
Const PI = 3.14159265
Const THE_TEXT = "Here is some text along an ellipse"

Dim cx As Single
Dim cy As Single
Dim theta As Single
Dim dtheta As Single
Dim xradius As Single
Dim yradius As Single
Dim i As Integer

    cx = ScaleWidth / 2
    cy = ScaleHeight / 2
    theta = PI
    dtheta = PI / Len(THE_TEXT)
    xradius = ScaleWidth * 0.45
    yradius = ScaleHeight * 0.45

    For i = 1 To Len(THE_TEXT)
        CurrentX = cx + xradius * Cos(theta)
        CurrentY = cy - yradius * Sin(theta)
        Print Mid$(THE_TEXT, i, 1);
        theta = theta - dtheta
    Next i
End Sub
 
For more information on advanced printing in Visual Basic, see my book Ready-to-Run Visual Basic Graphics Programming.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated