//! Draws the outline of a 2d rectangle void CNullDriver::draw2DRectangleOutline(const rectanglei& pos, SColor color) { draw2DLine(pos.UpperLeftCorner, position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), color); draw2DLine(position2di(pos.LowerRightCorner.X, pos.UpperLeftCorner.Y), pos.LowerRightCorner, color); draw2DLine(pos.LowerRightCorner, position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), color); draw2DLine(position2di(pos.UpperLeftCorner.X, pos.LowerRightCorner.Y), pos.UpperLeftCorner, color); }
//! Draws a non filled concyclic regular 2d polyon. void CNullDriver::draw2DPolygon(position2d<s32> center, f32 radius, SColor color, s32 count) { if (count < 2) return; position2d<s32> first; position2d<s32> a,b; for (s32 j=0; j<count; ++j) { b = a; f32 p = j / (f32)count * (PI*2); a = center + position2d<s32>((s32)(sin(p)*radius), (s32)(cos(p)*radius)); if (j==0) first = a; else draw2DLine(a, b, color); } draw2DLine(a, first, color); }
//========================================================================= // // 计算要画的直线,把点集合装到容器里去 // //========================================================================= void drawLine(const Line2D & line, std::vector<Point2D_int> & drawPointSet) { // 清空容器 drawPointSet.clear(); // 对要画的直线进行裁剪 Line2D clippedLine = line; // clippedLineFromRect 会修改传递进去的参数 line if (clippedLineFromRect(clippedLine, ClippingSize)) { // 计算出要画的直线的点的集合 draw2DLine(clippedLine, drawPointSet); // 开始画 for (const auto & point : drawPointSet) { glVertex2f(point.x , point.y); } } }