当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsPath类代码示例

本文整理汇总了C++中GraphicsPath的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsPath类的具体用法?C++ GraphicsPath怎么用?C++ GraphicsPath使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了GraphicsPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: graphics

int Window::drawLine(HDC hdc, int oy, std::wstring string, TextFont* fnt)
{
	using namespace Gdiplus;
	int x = (showed ? 0 : leftMargin) - 5;
	int y = (showed ? 0 : topMargin) + oy;
	const wchar_t* text = string.c_str();
	if (fnt == 0) fnt = font;

	Graphics graphics(hdc);
	graphics.SetSmoothingMode(SmoothingModeAntiAlias);

	FontFamily fontFamily;
	fnt->GetFamily(&fontFamily);

	RectF boundRect = fnt->getTextBounds(hdc, clientRect, text);

	x += ((clientRect.right - clientRect.left) - (int)(boundRect.GetRight() - boundRect.GetLeft()) - 2) / 2;
	y -= ((int)boundRect.GetBottom()) + 5;
	
	StringFormat strformat;

	GraphicsPath path;
	path.AddString(text, wcslen(text), &fontFamily, 
		fnt->GetStyle(), graphics.GetDpiY() * fnt->GetSize() / 72, Gdiplus::Point(x, y), &strformat );
	
	// Outline color + size
	Pen pen(Color(0, 0, 0), fnt->GetSize()/7);
	pen.SetLineJoin(LineJoinRound);
	graphics.DrawPath(&pen, &path);

	// Text color
	SolidBrush brush(Color(254, 254, 254));
	graphics.FillPath(&brush, &path);

	Rect bounds;
	path.GetBounds(&bounds, 0, &pen);

	return (int)boundRect.GetBottom();
}
开发者ID:Dreauw,项目名称:UltimateSubtitles,代码行数:39,代码来源:Window.cpp

示例2: penDraw

void CAngleLabel::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	PointF ptd[3];
	ptd[0] = pPt[1];
	ptd[1] = pPt[0];
	ptd[2] = pPt[2];

	Pen penDraw(Color(255, 0, 255, 0));
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetWidth((float)m_nWidth);
	
	GraphicsPath path;
	path.AddLines(ptd, m_nPtCount);

	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:22,代码来源:CAngleLabel.cpp

示例3: DrawString

bool DiffusedShadowStrategy::DrawString(
	Gdiplus::Graphics* pGraphics, 
	Gdiplus::FontFamily* pFontFamily,
	Gdiplus::FontStyle fontStyle,
	int nfontSize,
	const wchar_t*pszText, 
	Gdiplus::Rect rtDraw, 
	Gdiplus::StringFormat* pStrFormat)
{
	using namespace Gdiplus;
	GraphicsPath path;
	Status status = path.AddString(pszText,wcslen(pszText),pFontFamily,fontStyle,nfontSize,rtDraw,pStrFormat);
	if(status!=Ok)
		return false;

	for(int i=1; i<=m_nThickness; ++i)
	{
		Pen pen(m_clrOutline,i);
		pen.SetLineJoin(LineJoinRound);
		pGraphics->DrawPath(&pen, &path);
	}

	Status status2 = Ok;
	if(m_bOutlinetext==false)
	{
		for(int i=1; i<=m_nThickness; ++i)
		{
			SolidBrush brush(m_clrText);
			status2 = pGraphics->FillPath(&brush, &path);
		}
	}
	else
	{
		SolidBrush brush(m_clrText);
		status2 = pGraphics->FillPath(&brush, &path);
	}

	return status2 == Ok;
}
开发者ID:keperlia,项目名称:foo_uie_wsh_panel_mod_plus,代码行数:39,代码来源:DiffusedShadowStrategy.cpp

示例4: dc

void CMyDlg::OnPaint() 
{
	CPaintDC dc(this);
	CRect rcClient;
	GetClientRect(&rcClient);
	Graphics  graphics(dc); 
	if (version&&bIsAero) graphics.Clear(Color.Black);
	else graphics.Clear(Color.White);
	
	Bitmap CacheImage(rcClient.Width(),rcClient.Height());
	Graphics buffer(&CacheImage);
	buffer.SetSmoothingMode(SmoothingModeAntiAlias);
	buffer.SetInterpolationMode(InterpolationModeHighQualityBicubic);
	
	Image  *logo;
	Image  *button;
	ImageFromIDResource(2,"png",logo);
	ImageFromIDResource(1,"png",button);
	buffer.DrawImage(logo, -5,20);
	buffer.DrawImage(button, 165,122);
	buffer.DrawImage(button, 350,122);
	
	FontFamily fontFamily(version?L"微软雅黑":L"宋体");
	StringFormat strformat;
	wchar_t pszbuf[512];
	wsprintfW(pszbuf,L"本程序适用于 迅雷5.9 系列\n如果本软件有错,我概不负责,但我会尽力解决。\n只有极少数时候需要您指定安装目录(比如非官方版)。\n如果会员补丁失效,重新破解即可。\n\n\n请选择:    一键增强       %s取消增强\n\n2010年4月7日更新  www.shuax.com",version?L" ":L" ");
	GraphicsPath path;
	path.AddString(pszbuf, wcslen(pszbuf), &fontFamily, FontStyleRegular, version?15:16, Gdiplus::Point(version?90:80,version?9:20), &strformat );
	
	Pen pen(Color(18, 255, 255, 255), 3.0);
	//pen.SetLineJoin(LineJoinRound);
	buffer.DrawPath(&pen, &path);
	
	SolidBrush brush(Color(0,0,0));
	buffer.FillPath(&brush, &path);
	graphics.DrawImage(&CacheImage, 0, 0);
	graphics.ReleaseHDC(dc);
}
开发者ID:chenwp,项目名称:shuax,代码行数:38,代码来源:测试Dlg.cpp

示例5: MeasureString

bool TextDblOutlineStrategy::MeasureString(
    Gdiplus::Graphics* pGraphics,
    Gdiplus::FontFamily* pFontFamily,
    Gdiplus::FontStyle fontStyle,
    int nfontSize,
    const wchar_t*pszText,
    Gdiplus::Rect rtDraw,
    Gdiplus::StringFormat* pStrFormat,
    float* pfPixelsStartX,
    float* pfPixelsStartY,
    float* pfDestWidth,
    float* pfDestHeight )
{
    using namespace Gdiplus;
    GraphicsPath path;
    Status status = path.AddString(pszText,wcslen(pszText),pFontFamily,fontStyle,nfontSize,rtDraw,pStrFormat);
    if(status!=Ok)
        return false;

    *pfDestWidth= rtDraw.GetLeft();
    *pfDestHeight= rtDraw.GetTop();
    bool b = GDIPath::MeasureGraphicsPath(pGraphics, &path, pfPixelsStartX, pfPixelsStartY, pfDestWidth, pfDestHeight);

    if(false==b)
        return false;

    float pixelThick = 0.0f;
    b = GDIPath::ConvertToPixels(pGraphics,m_nThickness1+m_nThickness2,0.0f,NULL,NULL,&pixelThick,NULL);

    if(false==b)
        return false;

    *pfDestWidth += pixelThick;
    *pfDestHeight += pixelThick;

    return true;
}
开发者ID:shaovoon,项目名称:outline-text,代码行数:37,代码来源:TextDblOutlineStrategy.cpp

示例6: penDraw

void CNormalPen::SetRegion()
{
	PointF* pPt = m_ptary.GetData();

	int nWidth = m_nWidth;
	if(m_nWidth < 3)
	{
		nWidth = 3;
	}

	Pen penDraw(m_crColor,(float)nWidth);
	penDraw.SetDashStyle(m_nDashStyle);
	penDraw.SetStartCap(m_nStartCap);
	penDraw.SetEndCap(m_nEndCap);
	penDraw.SetLineJoin(LineJoinRound);

	GraphicsPath path;
	path.AddCurve(pPt,m_nPtCount);
	path.Widen(&penDraw);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:24,代码来源:CNormalPen.cpp

示例7: min

void CRectangle::SetRegion()
{
	float left = min(m_ptary[0].X,m_ptary[1].X);
	float top = min(m_ptary[0].Y,m_ptary[1].Y);
	float width = fabs(m_ptary[0].X - m_ptary[1].X);
	float height = fabs(m_ptary[0].Y - m_ptary[1].Y);
	/*PointF* pPt = m_ptary.GetData();*/

	int nWidth = m_nWidth;
	if(m_nWidth < 6)
	{
		nWidth = 6;
	}

	Pen greenPen(Color(255, 0, 255,  0), (float)nWidth);
	GraphicsPath path;
	if(RS_ROUND == m_nRStyle)
	{
		CRect rc((int)left,(int)top,(int)(left + width),(int)(top + height));
		INT offsetX = (rc.right - rc.left) * 20/100;  
		INT offsetY = (rc.bottom - rc.top) * 20/100;
		path.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
		path.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
		path.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
		path.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
		path.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);
	}
	else
	{

		RectF rcf(left,top,width,height);
		path.AddRectangle(rcf);
	}

	path.Widen(&greenPen);
	path.Outline();

	m_Region.MakeEmpty();
	m_Region.Union(&path);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:40,代码来源:CRectangle.cpp

示例8: CutawayPoints

void CRevisionGraphWnd::DrawRoundedRect (GraphicsDevice& graphics, const Color& penColor, int penWidth, const Pen* pen, const Color& fillColor, const Brush* brush, const RectF& rect, int mask)
{

	enum {POINT_COUNT = 8};

	float radius = CORNER_SIZE * m_fZoomFactor;
	PointF points[POINT_COUNT];
	CutawayPoints (rect, radius, points);

	if (graphics.graphics)
	{
		GraphicsPath path;

		if(mask & ROUND_UP)
		{
			path.AddArc (points[0].X, points[1].Y, radius, radius, 180, 90);
			path.AddArc (points[2].X, points[2].Y, radius, radius, 270, 90);
		}else
		{
			path.AddLine(points[0].X, points[1].Y, points[3].X, points[2].Y);
		}

		if(mask & ROUND_DOWN)
		{
			path.AddArc (points[5].X, points[4].Y, radius, radius, 0, 90);
			path.AddArc (points[7].X, points[7].Y, radius, radius, 90, 90);
		}else
		{
			path.AddLine(points[3].X, points[3].Y, points[4].X, points[5].Y);
			path.AddLine(points[4].X, points[5].Y, points[7].X, points[6].Y);
		}

		points[0].Y -= radius / 2;
		path.AddLine (points[7], points[0]);

		if (brush != NULL)
		{
			graphics.graphics->FillPath (brush, &path);
		}
		if (pen != NULL)
			graphics.graphics->DrawPath (pen, &path);
	}
	else if (graphics.pSVG)
	{
		graphics.pSVG->RoundedRectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height, penColor, penWidth, fillColor, (int)radius, mask);
	}

}
开发者ID:fabgithub,项目名称:TortoiseGit,代码行数:48,代码来源:RevisionGraphDlgDraw.cpp

示例9: MakeSmiley

void CQTTDemoView::MakeSmiley(GraphicsPath& path)
{
	path.Reset();	
	path.AddEllipse(200, 350, 400, 400);
	Rect rcEye(330, 520, 10, 10);
	path.AddEllipse(rcEye);
	rcEye.Offset(140, 0);
	path.AddEllipse(rcEye);
	Rect rcMouth(370, 590, 60, 60);
	path.AddArc(rcMouth, 0.0f, 180.0f);
	path.CloseFigure();
}
开发者ID:seancyw,项目名称:dev-center,代码行数:12,代码来源:QTTDemoView.cpp

示例10: GraphicsPath

GraphicsPath *GraphicsPathFromPathData(const char *s)
{
    VecSegmented<SvgPathInstr> instr;
    if (!ParseSvgPathData(s, instr))
        return nullptr;
    GraphicsPath *gp = ::new GraphicsPath();
    PointF prevEnd(0.f, 0.f);
    for (SvgPathInstr& i : instr) {
        PathInstrType type = i.type;

        // convert relative coordinates to absolute based on end position of
        // previous element
        // TODO: support the rest of instructions
        if (MoveRel == type) {
            RelPointToAbs(prevEnd, i.v);
            type = MoveAbs;
        } else if (LineToRel == type) {
            RelPointToAbs(prevEnd, i.v);
            type = LineToAbs;
        } else if (HLineRel == type) {
            RelXToAbs(prevEnd, i.v);
            type = HLineAbs;
        } else if (VLineRel == type) {
            RelYToAbs(prevEnd, i.v);
            type = VLineAbs;
        }

        if (MoveAbs == type) {
            PointF p(i.v[0], i.v[1]);
            prevEnd = p;
            gp->StartFigure();
        } else if (LineToAbs == type) {
            PointF p(i.v[0], i.v[1]);
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if (HLineAbs == type) {
            PointF p(prevEnd);
            p.X = i.v[0];
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if (VLineAbs == type) {
            PointF p(prevEnd);
            p.Y = i.v[0];
            gp->AddLine(prevEnd, p);
            prevEnd = p;
        } else if ((Close == type) || (Close2 == type)) {
            gp->CloseFigure();
        } else {
            CrashIf(true);
        }
    }
    return gp;
}
开发者ID:DBNinja,项目名称:sumatrapdf,代码行数:53,代码来源:SvgPath.cpp

示例11: TEST

TEST(GraphicsPathTest, transform) {
	GraphicsPath<double> path;
	path.moveto(0,0);
	path.lineto(1,0);
	path.lineto(1,1);
	path.lineto(0,1);
	path.closepath();
	Matrix m(1);
	m.scale(2,2);
	m.translate(10, 100);
	m.rotate(90);
	path.transform(m);
	ostringstream oss;
	path.writeSVG(oss, false);
	EXPECT_EQ(oss.str(), "M-100 10V12H-102V10Z");
}
开发者ID:thomas001,项目名称:dvisvgm,代码行数:16,代码来源:GraphicsPathTest.cpp

示例12: DrawRoundedRectangle

void DrawRoundedRectangle(Gdiplus::Graphics* gr, Gdiplus::Rect r, int d, Gdiplus::Pen* p, Gdiplus::Brush*br){
	using namespace Gdiplus;
	GraphicsPath gp;
//	d = min(min(d, r.Width),r.Height);
	gp.AddArc(r.X, r.Y, d, d, 180, 90);
	gp.AddArc(max(r.X + r.Width - d,r.X), r.Y, d, d, 270, 90);
	gp.AddArc(max(r.X, r.X + r.Width - d), max(r.Y, r.Y + r.Height - d), d, d, 0, 90);
	gp.AddArc(r.X, max(r.Y, r.Y + r.Height - d), d, d, 90, 90);
	gp.AddLine(r.X, max(r.Y, r.Y + r.Height - d), r.X, min(r.Y + d/2, r.GetBottom()));
	gp.CloseFigure();
	if ( br ) {
		gr->FillPath(br, &gp);
	}
	gr->DrawPath(p, &gp);

}
开发者ID:vladios13,项目名称:image-uploader,代码行数:16,代码来源:Utils.cpp

示例13: penDraw

void CRectangle::DrawRoundRect(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	INT offsetX = (rc.right - rc.left) * 20/100;  
	INT offsetY = (rc.bottom - rc.top) * 20/100;
	GraphicsPath pt;
	pt.AddArc(rc.right - offsetX, rc.top, offsetX, offsetY, 270, 90);
	pt.AddArc(rc.right - offsetX, rc.bottom - offsetY, offsetX, offsetY, 0, 90);
	pt.AddArc(rc.left, rc.bottom - offsetY, offsetX, offsetY, 90, 90);
	pt.AddArc(rc.left, rc.top, offsetX, offsetY, 180, 90);
	pt.AddLine(rc.left + offsetX, rc.top, rc.right - offsetX/2, rc.top);

	graph.DrawPath(&penDraw,&pt);
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:14,代码来源:CRectangle.cpp

示例14: GdipCreateRoundRect

GraphicsPath* GdipCreateRoundRect( Rect& rect, int nRadius )
{
	GraphicsPath roundRect;
	int nDiameter = nRadius << 1;
	Rect arcRect( 0, 0, nDiameter, nDiameter );

	arcRect.X = rect.GetLeft();
	arcRect.Y = rect.GetTop();
	roundRect.AddArc(arcRect, 180, 90);
	arcRect.X = rect.GetRight() - nDiameter;
	roundRect.AddArc(arcRect, 270, 90);
	arcRect.Y = rect.GetBottom() - nDiameter;
	roundRect.AddArc(arcRect, 0, 90);
	arcRect.X = rect.GetLeft();
	roundRect.AddArc(arcRect, 90, 90);
	roundRect.CloseFigure();

	return roundRect.Clone();
}
开发者ID:catcrying,项目名称:dumblebee-view,代码行数:19,代码来源:GdiplusExt.cpp

示例15: FillCylinder

 void FillCylinder(Graphics* pGfx, RectF rcClient,
     Brush* pFillBrush, Color cOutlineColor)
 {
     RectF rTopPlane(rcClient.X, rcClient.Y - 5, rcClient.Width, 5);
     RectF rBottomPlane(rcClient.X, rcClient.GetBottom() - 5, rcClient.Width, 5);
     // Outline pen
     Pen penOutline(cOutlineColor);
     // Draw body
     GraphicsPath gfxPath;
     gfxPath.AddArc(rTopPlane, 0, 180);
     gfxPath.AddArc(rBottomPlane, 180, -180);
     gfxPath.CloseFigure();
     // Fill body
     pGfx->FillPath(pFillBrush, &gfxPath);
     // Outline body
     pGfx->DrawPath(&penOutline, &gfxPath);
     // Draw top plane
     gfxPath.Reset();
     gfxPath.AddEllipse(rTopPlane);
     // Fill top plane
     pGfx->FillPath(pFillBrush, &gfxPath);
     // Outline top plane
     pGfx->DrawPath(&penOutline, &gfxPath);
 }
开发者ID:Budskii,项目名称:ulib-win,代码行数:24,代码来源:themometer.cpp


注:本文中的GraphicsPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。