用GDI+画长方体

// "cuboid.png"
void DrawCuboid(CDC *pDC)
{
Graphics graphics(pDC->m_hDC);
Point point1(50, 50); //    2       3
Point point2(100, 20);// 1      7
Point point3(200, 20);//
Point point4(50, 250);//
Point point5(150, 250);//           6
Point point6(200, 220);//4      5
Point point7(150,50);  //
// front :1,7,5,4
    Point frontPoints[4]={ point1 , point7 , point5, point4};
    RectF frontRect((float)point1.X,(float)point1.Y,
 (float)(point7.X-point1.X),
 (float)(point5.Y-point7.Y));
LinearGradientBrush frontB(frontRect,Color::Blue,Color::Aqua,LinearGradientModeHorizontal);// = 90.0f);//
graphics.FillPolygon(&frontB,frontPoints,4);
// right :7,3,6,5
    RectF rightRect((float)point7.X,(float)point7.Y,
 (float)(point3.X-point7.X),
 (float)(point5.Y-point3.Y));
    Point rightPoints[4]={ point7 , point3 , point6, point5};
LinearGradientBrush b(rightRect,Color::Aqua,Color::Blue,LinearGradientModeHorizontal);// = 90.0f);//
graphics.FillPolygon(&b,rightPoints,4);
// top :1,2,3,7
INT count = 4;
GraphicsPath rectPath;
    Point topPoints[4]={ point1 , point2 , point3, point7};
rectPath.AddPolygon(topPoints, count);
//
PathGradientBrush pathBrush(&rectPath);
//
Color cols[] = {Color::Blue, Color::Blue, Color::Blue, Color::Blue};
pathBrush.SetSurroundColors(cols, &count);
pathBrush.SetCenterColor(Color::Aqua);
pathBrush.SetCenterPoint(point7);
graphics.FillPolygon(&pathBrush, topPoints, count);
// draw  contour
Pen bluePen( Color(255,0,0,255),1);
Point points[6] = { point1 , point2 , point3, point6, point5, point4 };
graphics.DrawPolygon(&bluePen,points,6);
// draw 3 lines
graphics.DrawLine(&bluePen,point1,point7 );
graphics.DrawLine(&bluePen,point7,point3);
graphics.DrawLine(&bluePen,point5,point7);

}


阅读更多
文章标签: GDI+ Cuboid
个人分类: 计算机
上一篇给 OnPaint 加个 HDC 参数
下一篇VC 粘贴 CF_METAFILEPICT 格式 MetaFile
想对作者说点什么? 我来说一句

OpenGL绘制长方体

2012年09月28日 1.5MB 下载

没有更多推荐了,返回首页

关闭
关闭