本文整理汇总了C++中GraphicsPath::Transform方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsPath::Transform方法的具体用法?C++ GraphicsPath::Transform怎么用?C++ GraphicsPath::Transform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath::Transform方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GPDrawShadowText
void GPDrawShadowText( Graphics& gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB PenClrIn , ARGB shadowPenClrIn /*= 0xff000000*/, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
Gdiplus::Font& gcfont = fontIn;
FontFamily fmy;
gcfont.GetFamily(&fmy);
int nfontStyle = gcfont.GetStyle();
REAL dFontSize = gcfont.GetSize();
Rect rcText = CRect2Rect(rcIn);
StringFormat fmt;
fmt.SetAlignment(StringAlignmentCenter);
fmt.SetTrimming(StringTrimmingEllipsisWord);
fmt.SetLineAlignment(StringAlignmentCenter);
StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;
GraphicsContainer gcContainer = gc.BeginContainer();
gc.SetSmoothingMode(SmoothingModeAntiAlias);
CComBSTR btrTxtIn(strTxtIn);
GraphicsPath textPath;
textPath.AddString(btrTxtIn, -1, &fmy, nfontStyle, dFontSize, rcText, &fmtUse);
Matrix mx;
mx.Translate(nOffXIn, nOffYIn);
textPath.Transform(&mx);
Pen textPen(ARGB2Color(shadowPenClrIn), 1);
SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
textPen.SetLineJoin(LineJoinRound);
if (shadowBrushClrIn != 0)
{
gc.FillPath(&textbrush, &textPath);
}
if (shadowPenClrIn != 0)
{
gc.DrawPath(&textPen, &textPath);
}
mx.Invert();
textPath.Transform(&mx);
textPen.SetColor(ARGB2Color(PenClrIn));
textbrush.SetColor(ARGB2Color(BrushClrIn));
if (BrushClrIn != 0)
{
gc.FillPath(&textbrush, &textPath);
}
if (PenClrIn != 0)
{
gc.DrawPath(&textPen, &textPath);
}
gc.EndContainer(gcContainer);
}
示例2: Paint
void ButtonVector::Paint(Graphics *gfx, int offX, int offY)
{
if (!IsVisible())
return;
CachedStyle *s = cachedStyle;
RectF bbox((REAL)offX, (REAL)offY, (REAL)pos.Width, (REAL)pos.Height);
Brush *brBgColor = BrushFromColorData(s->bgColor, bbox);
gfx->FillRectangle(brBgColor, bbox);
Rect r(offX, offY, pos.Width, pos.Height);
DrawBorder(gfx, r, s);
if (!graphicsPath)
return;
// graphicsPath bbox can have non-zero X,Y
Rect gpBbox;
Brush *brFill = BrushFromColorData(s->fill, bbox);
Brush *brStroke = BrushFromColorData(s->stroke, bbox);
Pen pen(brStroke, s->strokeWidth);
pen.SetMiterLimit(1.f);
pen.SetAlignment(PenAlignmentInset);
if (0.f == s->strokeWidth)
graphicsPath->GetBounds(&gpBbox);
else
graphicsPath->GetBounds(&gpBbox, NULL, &pen);
// calculate the position of graphics path within given button position, size
// and desired vertical/horizontal alignment.
// Note: alignment is calculated against the size after substracting
// ncSize is the size of the non-client parts i.e. border and padding, on both sides
Size ncSize = GetBorderAndPaddingSize(s);
int elOffY = s->vertAlign.CalcOffset( gpBbox.Height, pos.Height - ncSize.Height);
int elOffX = s->horizAlign.CalcOffset(gpBbox.Width, pos.Width - ncSize.Width );
int x = offX + elOffX + s->padding.left + (int)s->borderWidth.left + gpBbox.X;
int y = offY + elOffY + s->padding.top + (int)s->borderWidth.top + gpBbox.Y;
// TODO: can I avoid making a copy of GraphicsPath?
GraphicsPath *tmp = graphicsPath->Clone();
Matrix m;
m.Translate((float)x, (float)y);
tmp->Transform(&m);
gfx->FillPath(brFill, tmp);
if (0.f != s->strokeWidth)
gfx->DrawPath(&pen, tmp);
}