본문 바로가기

Windows/MFC

[GDI+] RoundRect

[code]void DrawRoundRect(Gdiplus::Graphics* g, Pen *p, REAL X, REAL Y, REAL width, REAL height, REAL radius)
{
    if (g) return;
    GraphicsPath path;
    path.AddLine(X + radius, Y, X + width - (radius*2), Y);
    path.AddArc(X + width - (radius*2), Y, radius*2, radius*2, 270, 90);
    path.AddLine(X + width, Y + radius, X + width, Y + height - (radius*2));
    path.AddArc(X + width - (radius*2), Y + height - (radius*2), radius*2, radius*2, 0, 90);
    path.AddLine(X + width - (radius*2), Y + height, X + radius, Y + height);
    path.AddArc(X, Y + height - (radius*2), radius*2, radius*2, 90, 90);
    path.AddLine(X, Y + height - (radius*2), X, Y + radius);
    path.AddArc(X, Y, radius*2, radius*2, 180, 90);
    path.CloseFigure();
    g->DrawPath(p, &path);
}

void FillRoundRect(gdiplus::Graphics* g, Brush *p, REAL X, REAL Y, REAL width, REAL height, REAL radius)
{
    GraphicsPath path;

    path.AddLine(X + radius, Y, X + width - (radius*2), Y);
    path.AddArc(X + width - (radius*2), Y, radius*2, radius*2, 270, 90);
    path.AddLine(X + width, Y + radius, X + width, Y + height - (radius*2));
    path.AddArc(X + width - (radius*2), Y + height - (radius*2), radius*2, radius*2, 0, 90);
    path.AddLine(X + width - (radius*2), Y + height, X + radius, Y + height);
    path.AddArc(X, Y + height - (radius*2), radius*2, radius*2, 90, 90);
    path.AddLine(X, Y + height - (radius*2), X, Y + radius);
    path.AddArc(X, Y, radius*2, radius*2, 180, 90);
    path.CloseFigure();
    g->FillPath(p, &path);
}
[/code]

'Windows > MFC' 카테고리의 다른 글

Step by Step: Migrating an eMbedded Visual C++ Application to Visual Studio 2005  (0) 2013.10.02
[GDI+] 이미지에 Anti-aliasing (안티 알라이싱) 주기  (0) 2013.10.02
MulDiv  (0) 2013.10.02
GetSystemMetrics  (0) 2013.10.02
CTypedPtrList  (0) 2013.10.02