インストールレスプログラミング( ´ー`)

VBA , JavaScript , HTAなど 365アプリはインストール必要ですが、仕事に無いケースはほぼないから(・_・;)

ベジェ曲線の書き方はワカッタカモ

わかった気がしていたベジェ曲線

実際に書こうとして今度こそワカッタノカモシレナイ。

f:id:chemiphys:20170126225547p:plain

適当に描いたもののノードを書き出させたものです。

それをもとに,

Sub DrawTest()
Dim TargetSlide As Slide: Set TargetSlide = ActivePresentation.Slides(1)

With TargetSlide.Shapes.BuildFreeform(msoEditingAuto, 289.1612, 104.5161)
    .AddNodes msoSegmentCurve, msoEditingCorner, 305.7923, 76.90551, 403.587, 54.53126, 395.9999, 102.1935
    .AddNodes msoSegmentCurve, msoEditingCorner, 348.8234, 193.3442, 388.7014, 171.9131, 325.1612, 175.3547
    .AddNodes msoSegmentCurve, msoEditingCorner, 285.6703, 170.0691, 282.1794, 126.1654, 289.1612, 104.5161
    .ConvertToShape
End With
End Sub

(/・ω・)/
f:id:chemiphys:20170126225656p:plain

なるほど,

まず始点をBuildFreeformの引数で与える。
Addnodes msoSegmentCurve,msoEditingCorner で最後の引数まで与えると,
始点のコントロールポイント,終点のコントロールポイント,終点の順に座標を与えれる。これが1セット
前回の記事のところをもう一回載せておきます。

FreeformBuilder.AddNodes Method (PowerPoint)

Syntax
  expression .AddNodes(SegmentType, EditingType, X1, Y1, X2, Y2, X3, Y3)

If the EditingType of the new node is msoEditingCorner, this argument specifies the horizontal distance (in points) from the upper-left corner of the document to the first control point for the new segment.

これを繰り返していくだけで複雑な図形が書ける。

きわめてシンプルだけどこれはすごいな 面白い。

誤解してたから,この知識を持って明日は図形の再現に挑戦してみよう・・・と思うけど,明日そんな暇はあるのだろうか・・ないかもなぁ(ノД`)・゜・。