Option Explicit
Option Base 0
'
Const CONSTPAI As Double = 3.14159265358979 'π
'
Const DRGNSXPT As Integer = 110 '描画開始位置X
Const DRGNSYPT As Integer = 125 ' Y
Const DRGNLENG As Integer = 5 '辺の長さ
Const DRGNORDR As Integer = 10 '次数
Const DRGNLNCL As Long = &H701919 '線の色(濃紺)
Const DRGNLNWT As Single = 1 '線の太さ
'---------------------------------------------------------------
Public p_intDxp As Integer '描画位置X(変数)
Public p_intDyp As Integer ' Y(変数)
Public p_intAng As Integer '描画角度 (変数)
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Public Sub ドラゴン曲線描画マクロ()
'
p_intDxp = DRGNSXPT: p_intDyp = DRGNSXPT
p_intAng = 0
Call ドラゴン曲線描画マクロ_回帰(DRGNORDR, 90)
End Sub
'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Public Sub ドラゴン曲線描画マクロ_回帰(pintNum As Integer, pintAng As Integer)
Dim intExp As Integer, intEyp As Integer
Dim dblRad As Double
'
If pintNum = 0 Then
dblRad = p_intAng * CONSTPAI / 180
intExp = p_intDxp + DRGNLENG * Cos(dblRad)
intEyp = p_intDyp + DRGNLENG * Sin(dblRad)
With ActiveDocument.Shapes.AddLine( _
p_intDxp, p_intDyp, intExp, intEyp).Line
.ForeColor.RGB = DRGNLNCL '←線色
.Weight = DRGNLNWT '←線の太さ
End With
p_intDxp = intExp: p_intDyp = intEyp
'↓時間がかかるので、挿入しました。
DoEvents
Else
Call ドラゴン曲線描画マクロ_回帰(pintNum - 1, 90)
p_intAng = p_intAng + pintAng
Call ドラゴン曲線描画マクロ_回帰(pintNum - 1, -90)
End If
End Sub