S.5 Asteroidなど

目次のページ; 前のページ; 次のページ

 関数を作図させるとき、パラメータを変えると図形が変わる面白さがあります。下の例図はアステロイドですが、パラメータを変えた作図を例示しました。

Public Sub Proc5() ' Asteroid
    Dim n, k, Igra, a, x, y, Th
    n = Ivar
    Dperas
    Dpwind 0, 0, 640
    Dpmove 0, FormGraphic.ScaleTop
    Dpdraw 0, -FormGraphic.ScaleTop
    Dpmove -FormGraphic.ScaleLeft, 0
    Dpdraw FormGraphic.ScaleLeft, 0
    Igra = 0: k = 32
    For a = 20 To 200 Step 20
        For Th = 0 To 2 * pie + 0.1 Step pie / k
            x = a * Sgn(Cos(Th)) * Abs(Cos(Th) ^ n)
            y = a * Sgn(Sin(Th)) * Abs(Sin(Th) ^ n)
            DrawPolyLine x, y, Igra
        Next Th
        Igra = 0
    Next a
    If n = 3 Then
        Dptext 150, 170, "(Asteroid)"
    Else
        Dptext 150, 170, ("n =" + CStr(n))
    End If
End Sub

次のページ