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


C++ Graphics::DrawRectangle方法代码示例

本文整理汇总了C++中gdiplus::Graphics::DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::DrawRectangle方法的具体用法?C++ Graphics::DrawRectangle怎么用?C++ Graphics::DrawRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gdiplus::Graphics的用法示例。


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

示例1: DrawRectInt

    void CanvasGdiplus::DrawRectInt(const Color& color,
        int x, int y, int w, int h)
    {
        Gdiplus::Pen pen(color.GetNativeColor());

        Gdiplus::Graphics* current = GetCurrentGraphics();
        current->DrawRectangle(&pen, x, y, w, h);
    }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:8,代码来源:canvas_gdiplus.cpp

示例2: Draw

void CRectangle::Draw(Gdiplus::Graphics& graphics)
{
	// SolidBrush brush(Color::Black);
	SolidBrush brush(_fill_color);
	graphics.FillRectangle(&brush, _rect);

	Pen pen(_border_color, 5);
	graphics.DrawRectangle(&pen, _rect);
}
开发者ID:Catherine0320,项目名称:weekends2015,代码行数:9,代码来源:Rectangle.cpp

示例3: DrawGame

void DrawGame(Gdiplus::Graphics &graphics, Game &currentGame)
{
	// Draw background.
	graphics.FillRectangle(MY_WHITE_BRUSH, 0, 0, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
	
	// Draw end.
	const MazeState &currentMazeState = currentGame.CurrentState();
	
	graphics.FillRectangle(
		WEAK_BLACK_BRUSH,
		static_cast<INT>(currentMazeState.end[0] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(currentMazeState.end[1] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 5),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 5));
	
	// Draw player.
	graphics.FillEllipse(
		MY_RED_BRUSH,
		static_cast<INT>(currentMazeState.currentPosition[0] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(currentMazeState.currentPosition[1] * MAZE_GRID_CELL_SIZE + 2),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 4),
		static_cast<INT>(MAZE_GRID_CELL_SIZE - 4));
	
	// Draw maze jumps.
	int numJumps = currentMazeState.jumps.size();
	for (int i = 0; i < numJumps; ++i) {
		graphics.FillEllipse(
			MY_BLUE_BRUSH,
			static_cast<INT>(currentMazeState.jumps[i].array[0] * MAZE_GRID_CELL_SIZE + 3),
			static_cast<INT>(currentMazeState.jumps[i].array[1] * MAZE_GRID_CELL_SIZE + 3),
			static_cast<INT>(MAZE_GRID_CELL_SIZE - 5),
			static_cast<INT>(MAZE_GRID_CELL_SIZE - 5));
	}
	
	// Draw maze.
	graphics.DrawRectangle(
		MY_BLACK_PEN,
		0, 0,
		MAZE_GRID_CELL_SIZE * MAZE_GRID_WIDTH, MAZE_GRID_CELL_SIZE * MAZE_GRID_HEIGHT);
	
	for (int j = 0; j < MAZE_GRID_HEIGHT; ++j) {
		for (int i = 0; i < MAZE_GRID_WIDTH; ++i) {
			if (currentMazeState.cellFlags[j][i] & CELL_WALL_UP) {
				graphics.DrawLine(
					MY_BLACK_PEN,
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * j),
					static_cast<INT>(MAZE_GRID_CELL_SIZE * (i+1)), static_cast<INT>(MAZE_GRID_CELL_SIZE * j));
			}
			if (currentMazeState.cellFlags[j][i] & CELL_WALL_LEFT) {
				graphics.DrawLine(
					MY_BLACK_PEN,
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * j),
					static_cast<INT>(MAZE_GRID_CELL_SIZE * i), static_cast<INT>(MAZE_GRID_CELL_SIZE * (j+1)));
			}
		}
	}
}
开发者ID:Veltas,项目名称:recursive-maze-game,代码行数:57,代码来源:draw_game.cpp

示例4: DrawFocusRect

 void CanvasGdiplus::DrawFocusRect(int x, int y, int width, int height)
 {
     // WLW TODO: fix it.
     //HDC dc = BeginPlatformPaint();
     //::DrawFocusRect(dc, &(Rect(x, y, width, height).ToRECT()));
     //EndPlatformPaint(dc);
     Gdiplus::Graphics* current = GetCurrentGraphics();
     Gdiplus::Pen pen(Gdiplus::Color::Gray);
     pen.SetDashStyle(Gdiplus::DashStyleDot);
     current->DrawRectangle(&pen, x, y, width-1, height-1);
 }
开发者ID:Strongc,项目名称:Chrome_Library,代码行数:11,代码来源:canvas_gdiplus.cpp

示例5: draw

void MyRectangle::draw(Gdiplus::Graphics &graphics)
{
	int topleft_x = start_point.X < end_point.X ? start_point.X : end_point.X;
	int topleft_y = start_point.Y < end_point.Y ? start_point.Y : end_point.Y;

	int bottomright_x = start_point.X > end_point.X ? start_point.X : end_point.X;
	int bottomright_y = start_point.Y > end_point.Y ? start_point.Y : end_point.Y;

	int width = bottomright_x - topleft_x;
	int height = bottomright_y - topleft_y;

	graphics.DrawRectangle(m_pen.get(),topleft_x,topleft_y,width,height);
}
开发者ID:tianskylan,项目名称:Painting-Application,代码行数:13,代码来源:MyRectangle.cpp

示例6: OnDrawTop

void CGuideRectODL::OnDrawTop( Gdiplus::Graphics& gcDrawer , float fScale)
{
	CBaseODL::OnDrawTop(gcDrawer, fScale);
	
	CArray<Gdiplus::Point> st;
	if (m_rtArea.Width<1.0f)
	{
		return;
	}
	Gdiplus::Pen pen( m_clPenColor, 1.0f / fScale);
	pen.SetDashStyle( Gdiplus::DashStyleSolid);

	gcDrawer.DrawRectangle(&pen, m_rtArea);
}
开发者ID:litao1009,项目名称:SimpleRoom,代码行数:14,代码来源:GuideRectODL.cpp

示例7: DrawRect

void GdiplusGfx::DrawRect(const GfxRect& r, GfxCol col, float width)
{
    Pen p(Color(GfxColToARGB(col)), width);
    PenAlignment a = p.GetAlignment();
    plogf("a = %d", (int)a);
    p.SetAlignment(PenAlignmentInset);
#if 1
    float x = (float)r.x - 0.5f;
    float y = (float)r.y - 0.5f;
#else
    float x = (float)r.x;
    float y = (float)r.y;
#endif
    float dx = (float)r.dx;
    float dy = (float)r.dy;
    Gdiplus::RectF r2(x, y, dx, dy);
    g->DrawRectangle(&p, r2);
}
开发者ID:eminemence,项目名称:advancedoptionsui-sumatrapdf,代码行数:18,代码来源:MuiTest.cpp

示例8: OnDrawTop

void CSkyODL::OnDrawTop(Gdiplus::Graphics& gcDrawer, float fScale)
{
	CBaseODL::OnDrawTop(gcDrawer, fScale);
	
	Gdiplus::Pen Dot( m_clDotColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
	CArray<Gdiplus::Point> st;
	CArray<Gdiplus::Point> stMoving;
	CArray<BYTE> stBytes;

	for (auto& curItem : m_arrTopPoint)
	{
		Gdiplus::Point pt;
		pt.X = static_cast<INT>(curItem.X());
		pt.Y = static_cast<INT>(curItem.Z());
		st.Add(pt);
	}
	if (IsTopMoving())
	{
		for ( auto& curMoving : m_arrMovingTopPoint )
		{
			Gdiplus::Point pt;
			pt.X = static_cast<INT>(curMoving.X());
			pt.Y = static_cast<INT>(curMoving.Z());
			stMoving.Add(pt);
		}
	}
	if(st.GetSize()<=0)
	{
		return;
	}
	for (int i=0; i<st.GetSize(); ++i)
	{
		st[i].X = static_cast<INT>(st[i].X);
		st[i].Y = static_cast<INT>(st[i].Y);
	}
	for (int i=0; i<stMoving.GetSize(); ++i)
	{
		stMoving[i].X = static_cast<INT>(stMoving[i].X);
		stMoving[i].Y = static_cast<INT>(stMoving[i].Y);
	}
	Gdiplus::Pen pen( m_clPenColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
	pen.SetDashStyle(Gdiplus::DashStyleSolid);

	if (!IsTopCreating())
	{
		Gdiplus::HatchBrush brush( Gdiplus::HatchStyle(Gdiplus::HatchStyle::HatchStyleCross ), m_clPenColor, Gdiplus::Color(0,255,255,255) );
		//画皮肤
		gcDrawer.FillPolygon(&brush, st.GetData(), st.GetSize(), Gdiplus::FillMode::FillModeAlternate);
	}

	gcDrawer.DrawLines(&pen, st.GetData(), st.GetSize());

	if (IsTopMoving())
	{
		Gdiplus::Pen penMoving( m_clDotColor, static_cast<Gdiplus::REAL>(1.0 / fScale));
		penMoving.SetDashStyle( Gdiplus::DashStyleSolid);
		gcDrawer.DrawLines(&penMoving, stMoving.GetData(), stMoving.GetSize());
	}
	if (IsTopSelected())
	{
		//每个转角画一个点
		for (int x=0; x<st.GetSize(); x++)
		{
			gcDrawer.DrawRectangle(&Dot, (st[x].X) - 3.0f/fScale, (st[x].Y ) - 3.0f/fScale, 6.0f/fScale, 6.0f/fScale);
		}
	}
}
开发者ID:litao1009,项目名称:SimpleRoom,代码行数:67,代码来源:SkyODL.cpp

示例9: draw_rect

		void draw_rect(const Rect* r)
		{
			Gdiplus::Pen* pen = new Gdiplus::Pen(*color, (Gdiplus::REAL)width);
			graphics->DrawRectangle(pen, (Gdiplus::REAL)r->x, (Gdiplus::REAL)r->y, (Gdiplus::REAL)r->w, (Gdiplus::REAL)r->h);
			delete pen;
		}
开发者ID:ChinaCCF,项目名称:Fortunes,代码行数:6,代码来源:Render.cpp

示例10: DrawRectangle

void Graphics::DrawRectangle(Pen* pen, const Rect& rc) {
    Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
    Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);
    g->DrawRectangle(gdiPen, ToGDIRect<Rect, Gdiplus::Rect>(rc));
}
开发者ID:pixelspark,项目名称:corespark,代码行数:5,代码来源:tjgraphics-gdiplus.cpp


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