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);
}
    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);
    }
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)));
			}
		}
	}
}
 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);
 }
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);
}
Beispiel #6
0
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);
}
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);
}
Beispiel #8
0
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);
		}
	}
}
Beispiel #9
0
		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;
		}
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));
}