Microsoft Office Tutorials and References
In Depth Information
Figure A-4. Random stars spelling a name
' Starting position
StartLeft = ActiveCell.Left
StartTop = ActiveCell.Top
sName = "Steven Roman"
n = 5
k = Len(sName)
sSize = Application.InchesToPoints(0.5)
Randomize Timer
z = 0#
' Loop for first curve with phase shift
For i = 1 To k
If Mid(sName, i, 1) <> " " Then
x = n * i / k
x = Application.InchesToPoints(x)
' Get random 0 or 1. Go up or down accordingly.
If Int(2 * Rnd) = 0 Then
z = z + 0.2
Else
z = z - 0.2
End If
y = Application.InchesToPoints(z)
Set sh = ActiveSheet.Shapes.AddShape _
(msoShape5pointStar, StartLeft + x, StartTop + y, sSize,
sSize)
' Add shading
sh.Fill.ForeColor.RGB = RGB(230, 230, 230)
sh.Fill.Visible = msoTrue
' Add text
sh.TextFrame.Characters.Text = Mid(sName, i, 1)
sh.TextFrame.Characters.Font.Size = 10
sh.TextFrame.Characters.Font.Name = "Arial"
sh.TextFrame.Characters.Font.Bold = True
End If
Next i
End Sub
The output from this code is shown in Figure A-4 .
Figure A-4. Random stars spelling a name
Example A-6 prints a hypocycloid. (It may take a few minutes to complete.)
Example A-6. The DrawHypocycloid Procedure
 
 
 
 
Search JabSto ::




Custom Search