【Word VBA】毛卍文模様描画マクロ▽ソースコード

記事
IT・テクノロジー
HC220816A.png

Option Explicit
Option Base 0
'
Public Sub 毛卍文模様描画マクロ()
    Const HRSWLEFT = 100               '描画開始位置X
    Const HRSWTOPP = 120              '      Y
    '
    Const HRSWHZSP = 25                '水平間隔
    Const HRSWVTSP = 70                '垂直間隔
    Const HRSWCOLS = 4                 '横 描画数
    Const HRSWROWS = 6                '縦 描画数
    '
    Const HRSWPTCN = 15               '花びら枚数
    Const HRSWRADI = 10               '輪の半径
    Const HRSWMOWD = 6              '花びらの幅
    Const HRSWMOHT = 12             '花びらの長さ
    Const HRSWMORT = 0.35           '曲がり比率
    '---------------------------------------------------------------------------
    Dim Ip As Integer, Jp As Integer
    Dim Kp As Integer, lngCol As Long
    Dim intCxp As Integer, intCyp As Integer
    Dim intDxp As Integer, intDyp As Integer
    Dim intAng As Integer, dblSit As Double
    '
    dblSit = (8 * Atn(1)) / HRSWPTCN: intAng = 360 / HRSWPTCN
    '
    lngCol = RGB(255, 20, 147)               '←花びらの色
    For Jp = 0 To HRSWROWS - 1
        intCyp = HRSWLEFT + HRSWHZSP * Jp
        For Ip = 0 To HRSWCOLS - 1
            If (Jp Mod 2) = 0 Or Ip < HRSWCOLS - 1 Then
               intCxp = HRSWLEFT + HRSWVTSP * Ip  _
                        + (HRSWVTSP / 2) * (Jp Mod 2)
               For Kp = 0 To HRSWPTCN - 1
                   intDxp = HRSWRADI * Cos(dblSit * Kp) + intCxp
                   intDyp = HRSWRADI * Sin(dblSit * Kp) + intCyp
       '花びら描画
                   With ActiveDocument.Shapes.AddShape(msoShapeMoon, _
                         intDxp - HRSWMOWD / 2, _
                         intDyp - HRSWMOHT / 2, _
                         HRSWMOWD, HRSWMOHT)
                        .Fill.ForeColor.RGB = lngCol         '←塗りつぶし色
                        .Fill.Visible = msoTrue                 '←塗りつぶし有無
                        .Line.Visible = msoFalse              '←線の有無
               '
                        .Adjustments(1) = HRSWMORT
                        .Rotation = intAng * (Kp + 1) + 90
                   End With
              Next Kp
            End If
        Next Ip
   Next Jp
End Sub

《蛇足》
 自分が描いていないけど、実行時間が長いマクロで描かれたものには、
 愛着が増す。

サービス数40万件のスキルマーケット、あなたにぴったりのサービスを探す