本文整理汇总了C++中gdiplus::Graphics::DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::DrawLine方法的具体用法?C++ Graphics::DrawLine怎么用?C++ Graphics::DrawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdiplus::Graphics
的用法示例。
在下文中一共展示了Graphics::DrawLine方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSeparator
void CStartupView::DrawSeparator(Gdiplus::Graphics &graphics)
{
Gdiplus::Rect gdipRcLogoRegion;
Gdiplus::Rect gdipRcButtonRegion;
Gdiplus::Rect gdipRcBottomRegion;
CalculateRegions(gdipRcLogoRegion, gdipRcButtonRegion, gdipRcBottomRegion);
Gdiplus::Pen greyPen(Gdiplus::Color(255, 190, 190, 190), 1);
// horizontal separator on the left side
Gdiplus::Rect gdipRcLeftButtons;
CalculateLeftButtonsRegion(gdipRcLeftButtons);
int x1 = gdipRcLeftButtons.X + SEPARATOR_SPACE;
int y1 = gdipRcLeftButtons.Y + BUTTON_TITLE_HEIGHT + BUTTON_SUBTITLE_HEIGHT +
2 * BUTTON_HEIGHT + SEPARATOR_HEIGHT/2.0;
int x2 = gdipRcLeftButtons.X + gdipRcLeftButtons.Width - SEPARATOR_SPACE;
int y2 = y1;
graphics.DrawLine(&greyPen, x1, y1, x2, y2);
// vertical separator in the middle of the page
x1 = gdipRcButtonRegion.X + gdipRcButtonRegion.Width / 2.0;
y1 = gdipRcLeftButtons.Y + SEPARATOR_SPACE;
x2 = x1;
y2 = gdipRcLeftButtons.Y + gdipRcLeftButtons.Height - SEPARATOR_SPACE;
graphics.DrawLine(&greyPen, x1, y1, x2, y2);
}
示例2: DrawGame
void DrawGame(Gdiplus::Graphics &graphics, Game ¤tGame)
{
// Draw background.
graphics.FillRectangle(MY_WHITE_BRUSH, 0, 0, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
// Draw end.
const MazeState ¤tMazeState = 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)));
}
}
}
}
示例3: DrawLineInt
void CanvasGdiplus::DrawLineInt(const Color& color,
int x1, int y1, int x2, int y2)
{
Gdiplus::Pen pen(color.GetNativeColor());
Gdiplus::Graphics* current = GetCurrentGraphics();
current->DrawLine(&pen, x1, y1, x2, y2);
}
示例4: rc
void CSkinButton2::DrawFrame(Gdiplus::Graphics& gdi,CRect& rect)
{
if( m_enmuDrawType == NO_FRAME )
{
Gdiplus::Pen pen1( m_colFrame1 );
gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );
Gdiplus::Color colpix;
pen1.GetColor( &colpix );
colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
Gdiplus::Pen penPix1( colpix );
gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &penPix1, rect.left, rect.bottom-1, rect.left+1, rect.bottom-1 );
CRect rect2 = rect;
::InflateRect( &rect2, -1,-1 );
if( !m_bMouseDown )
{
Gdiplus::Pen pen2(m_colFrame2);
if( m_bMouseDown )
pen2.SetColor(m_colFrame1);
else
pen2.SetColor(m_colFrame2);
gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );
Gdiplus::Color colpix2;
pen2.GetColor( &colpix2 );
colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
Gdiplus::Pen penPix2( colpix2 );
gdi.DrawLine( &penPix2, rect2.left, rect2.top, rect2.left+1, rect2.top );
gdi.DrawLine( &penPix2, rect2.right-1, rect2.top, rect2.right-1, rect2.top+1 );
gdi.DrawLine( &penPix2, rect2.right-1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &penPix2, rect2.left, rect2.bottom-1, rect2.left+1, rect2.bottom-1 );
}
if( m_bMouseDown )
{
Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/3 );
Gdiplus::Color colBrush1,colBrush2;
colBrush1.SetValue( Gdiplus::Color::MakeARGB(15,1,1,1) );
colBrush2.SetValue( Gdiplus::Color::MakeARGB(0,1,1,1) );
LinearGradientBrush brush( rc, colBrush1, colBrush2,LinearGradientModeVertical );
gdi.FillRectangle( &brush, rc );
}
else
{
Gdiplus::RectF rc( rect2.left, rect2.top, rect2.Width(), rect2.Height()/2 );
rc.Inflate(-1,-1);
LinearGradientBrush brush( rc, m_colBrush1, m_colBrush2,LinearGradientModeVertical );
gdi.FillRectangle( &brush, rc );
}
return;
}
else if( m_enmuDrawType == NO_FRAME_SELECT )
{
Gdiplus::Pen pen1( m_colFrame1 );
gdi.DrawLine( &pen1, rect.left+1, rect.top, rect.right-2, rect.top );
gdi.DrawLine( &pen1, rect.left+1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &pen1, rect.left, rect.top+1, rect.left, rect.bottom-2 );
gdi.DrawLine( &pen1, rect.right-1, rect.top+1, rect.right-1, rect.bottom-2 );
Gdiplus::Color colpix;
pen1.GetColor( &colpix );
colpix.SetValue( Gdiplus::Color::MakeARGB(colpix.GetA()/2,colpix.GetR(),colpix.GetG(),colpix.GetB() ) );
Gdiplus::Pen penPix1( colpix );
gdi.DrawLine( &penPix1, rect.left, rect.top, rect.left+1, rect.top );
gdi.DrawLine( &penPix1, rect.right-1, rect.top, rect.right-1, rect.top+1 );
gdi.DrawLine( &penPix1, rect.right-1, rect.bottom-1, rect.right-2, rect.bottom-1 );
gdi.DrawLine( &penPix1, rect.left, rect.bottom-1, rect.left+1, rect.bottom-1 );
CRect rect2 = rect;
::InflateRect( &rect2, -1,-1 );
if( !m_bMouseDown )
{
Gdiplus::Pen pen2(m_colFrame2);
if( m_bMouseDown )
pen2.SetColor(m_colFrame1);
else
pen2.SetColor(m_colFrame2);
gdi.DrawLine( &pen2, rect2.left+1, rect2.top, rect2.right-2, rect2.top );
gdi.DrawLine( &pen2, rect2.left+1, rect2.bottom-1, rect2.right-2, rect2.bottom-1 );
gdi.DrawLine( &pen2, rect2.left, rect2.top+1, rect2.left, rect2.bottom-2 );
gdi.DrawLine( &pen2, rect2.right-1, rect2.top+1, rect2.right-1, rect2.bottom-2 );
Gdiplus::Color colpix2;
pen2.GetColor( &colpix2 );
colpix2.SetValue( Gdiplus::Color::MakeARGB(colpix2.GetA()/2,colpix2.GetR(),colpix2.GetG(),colpix2.GetB() ) );
Gdiplus::Pen penPix2( colpix2 );
//.........这里部分代码省略.........
示例5: Draw
void CLine::Draw(Gdiplus::Graphics& graphics)
{
Pen pen(Color::Red);
graphics.DrawLine(&pen, _point1, _point2);
}
示例6: draw
// overload the pure virtual draw() from base class
void MyLine::draw(Gdiplus::Graphics& graphics) {
graphics.DrawLine(m_Pen.get(), m_StartPoint.X, m_StartPoint.Y, m_EndPoint.X, m_EndPoint.Y);
}
示例7: draw_line
void draw_line(Point* p1, Point* p2)
{
Gdiplus::Pen* pen = new Gdiplus::Pen(*color, (Gdiplus::REAL)width);
graphics->DrawLine(pen, TO_POINT(p1), TO_POINT(p2));
delete pen;
}
示例8: DrawLine
void Graphics::DrawLine(Pen* pen, int xa, int ya, int xb, int yb) {
Gdiplus::Graphics* g = reinterpret_cast<Gdiplus::Graphics*>(_private);
Gdiplus::Pen* gdiPen = reinterpret_cast<Gdiplus::Pen*>(pen->_private);
g->DrawLine(gdiPen, xa, ya, xb, yb);
}