Word VBAによるグラフィックス描画の例
プログラム − リサージュ図形を描く
パラメータの値は適当に変更してください。
Sub Draw_Lissajous() Dim i, d, de, alpha, beta Dim w1, w2, a, b Const Pi = 3.1415926535898 InitializeGraphics SetViewPort 100, 100, 500, 370 ' use almost the top half area of portrait A4 size paper SetGraphicsWindow -30, -20, 30, 20 gLineWidth = 2 a = 30 b = -20 alpha = 0 beta = 0 d = Pi * 2 / 180 de = 3 * Pi + d w1 = 4 w2 = 5 Lissajous a, b, d, de, w1, w2, alpha, beta, i End Sub Sub Lissajous(a, b, d, de, w1, w2, alpha, beta, c) Dim T, x1, y1, x2, y2 DrawAxis a, b x1 = a * Sin(alpha) y1 = b * Sin(beta) For T = d To de Step d x2 = a * Sin(w1 * T + alpha) y2 = b * Sin(w2 * T + beta) DrawLine x1, y1, x2, y2, QBColor(c) x1 = x2 y1 = y2 Next T End Sub Sub DrawAxis(a, b) DrawLine -a, 0, a, 0 DrawLine 0, b, 0, -b End Sub