本文整理汇总了C++中GiGraphics::drawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ GiGraphics::drawLine方法的具体用法?C++ GiGraphics::drawLine怎么用?C++ GiGraphics::drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GiGraphics
的用法示例。
在下文中一共展示了GiGraphics::drawLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void GcGraphView::draw(GiGraphics& gs)
{
int gridType = cmdView()->getOptionInt("showGrid", 0);
if (gridType < 1 || gridType > 2 || gs.xf().getViewScale() < 0.05f)
return;
Box2d rect(gs.xf().getWndRectW());
GiContext ctx(0, GiColor(127, 127, 127, gridType == 2 ? 48 : 20));
if (gridType == 1) {
GiContext ctx5(0, GiColor(127, 127, 127, 48));
float x = mgbase::roundReal(rect.xmin, -1) - 10;
float y = mgbase::roundReal(rect.ymin, -1) - 10;
int i = mgRound(x) / 10;
for (; x < rect.xmax + 10; x += 10) {
gs.drawLine(i++ % 5 ? &ctx : &ctx5, Point2d(x, rect.ymin), Point2d(x, rect.ymax), false);
}
i = mgRound(y) / 10;
for (; y < rect.ymax + 10; y += 10) {
gs.drawLine(i++ % 5 ? &ctx : &ctx5, Point2d(rect.xmin, y), Point2d(rect.xmax, y), false);
}
}
else if (gridType == 2) {
for (float x = rect.xmin - 10; x < rect.xmax + 10; x += 10) {
for (float y = rect.ymin - 10; y < rect.ymax + 10; y += 10) {
gs.drawLine(&ctx, Point2d(x, y - 0.5f), Point2d(x, y + 0.5f), false);
gs.drawLine(&ctx, Point2d(x - 0.5f, y), Point2d(x + 0.5f, y), false);
}
}
}
GcBaseView::draw(gs);
}
示例2: _draw
bool MgArc::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const
{
bool ret = gs.drawArc(&ctx, getCenter(), getRadius(), 0, getStartAngle(), getSweepAngle());
if (mode > 0) {
GiContext ctxln(0, GiColor(0, 126, 0, 64), kGiLineDashDot);
gs.drawLine(&ctxln, getCenter(), getStartPoint());
gs.drawLine(&ctxln, getCenter(), getEndPoint());
gs.drawLine(&ctxln, getStartPoint(), getStartPoint() + getStartTangent());
gs.drawLine(&ctxln, getEndPoint(), getEndPoint() + getEndTangent());
}
return __super::_draw(mode, gs, ctx, segment) || ret;
}
示例3: _draw
bool MgGrid::_draw(int mode, GiGraphics& gs, const GiContext& ctx) const
{
Vector2d cell(m_cell / 2);
if (cell.x < _MGZERO || cell.y < _MGZERO) {
GiContext ctxedge(ctx);
ctxedge.setNoFillColor();
gs.drawRect(&ctxedge, getRect());
return __super::_draw(mode, gs, ctx);
}
int nx = (int)(getWidth() / cell.x + _MGZERO);
int ny = (int)(getHeight() / cell.y + _MGZERO);
Box2d rect(getPoint(3), getPoint(3)
+ Vector2d((float)(cell.x * nx), (float)(cell.y * ny)));
float w = gs.calcPenWidth(ctx.getLineWidth(), ctx.isAutoScale()) / -2.f;
GiContext ctxgrid(w, ctx.getLineColor());
bool antiAlias = gs.setAntiAliasMode(false);
int ret = gs.drawRect(&ctxgrid, rect) ? 1 : 0;
bool switchx = (nx >= 10 && cell.x < gs.xf().displayToModel(20, true));
bool switchy = (ny >= 10 && cell.y < gs.xf().displayToModel(20, true));
Point2d pts[2] = { rect.leftTop(), rect.leftBottom() };
for (int i = 1; i < nx; i++) {
pts[0].x += cell.x;
pts[1].x += cell.x;
ctxgrid.setLineWidth(!switchx || i%5 > 0 ? w/2 : w, false);
ctxgrid.setLineAlpha(-w < 0.9f && (!switchx || i%5 > 0) ?
ctx.getLineAlpha() / 2 : ctx.getLineAlpha());
ret += gs.drawLine(&ctxgrid, pts[0], pts[1]) ? 1 : 0;
}
pts[0] = rect.leftBottom();
pts[1] = rect.rightBottom();
for (int j = 1; j < ny; j++) {
pts[0].y += cell.y;
pts[1].y += cell.y;
ctxgrid.setLineWidth(!switchy || j%5 > 0 ? w/2 : w, false);
ctxgrid.setLineAlpha(-w < 0.9f && (!switchy || j%5 > 0) ?
ctx.getLineAlpha() / 2 : ctx.getLineAlpha());
ret += gs.drawLine(&ctxgrid, pts[0], pts[1]) ? 1 : 0;
}
gs.setAntiAliasMode(antiAlias);
return __super::_draw(mode, gs, ctx) || ret > 0;
}
示例4: drawBox
bool MgImageShape::drawBox(GiGraphics& gs, const GiContext& ctx) const
{
GiContext tmpctx(ctx);
tmpctx.setNoFillColor();
tmpctx.setLineStyle(GiContext::kSolidLine);
GiContext ctxline(tmpctx);
ctxline.setLineWidth(0, false);
return (gs.drawPolygon(&tmpctx, 4, _points)
&& gs.drawLine(&ctxline, _points[0], _points[2])
&& gs.drawLine(&ctxline, _points[1], _points[3]));
}
示例5: _draw
bool MgLine::_draw(GiGraphics& gs, const GiContext& ctx) const
{
bool ret = gs.drawLine(&ctx, _points[0], _points[1]);
return __super::_draw(gs, ctx) || ret;
}
示例6: _draw
bool MgLine::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const
{
bool ret = gs.drawLine(&ctx, _points[0], _points[1]);
return __super::_draw(mode, gs, ctx, segment) || ret;
}