0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

MFCからSVG変換Advent Calendar 2022

Day 20

MFC から SVG クラスの円弧呼び出しコードサンプル

Last updated at Posted at 2022-12-19

MFC(GDI+) と SvgImage の円弧出力

MFC(GDI+) の場合以下のようになります。

    Gdiplus::Pen pen(Color(255, 0, 0, 0));
	pGraphics->DrawArc(&pen, 100, 50, 140, 70, 30, 180);

SvgImage に書き出すと以下のようになります。

	pSvgImage->AddArc(100, 50, 140, 70, 30, 180);
    pImage->AddAttrStroke(RGB(0, 0, 0), 1, PS_SOLID);

MFC(GDI+) は円弧などをパス出力した際にベジェ曲線に書き換えられます。
角が円弧の多角形などを描く際に便利ですのでパスに出力したいときもあると思います。
パスとして SvgImage に書き出す場合は以下の通りです。

    Gdiplus::GraphicsPath path;
    path.AddArc(100, 50, 140, 70, 30, 180);
    Gdiplus::PathData pathData;
    path.GetPathData(&pathData);
    pSvgImage->AddPathData(&pathData);
    pImage->AddAttrStroke(RGB(0, 0, 0), 1, PS_SOLID);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?