Stroking a path only inside/outside?

允我心安 提交于 2019-12-03 17:21:40

Your best bet is probably QPainterPathStroker. Use it to create a new path that's the outline of your path. Then use QPainterPath operations like intersection or subtraction between the two:

outsidePath = strokedPath.subtracted(originalPath);
insidePath = strokedPath.intersected(originalPath);

A better approach is to set the blending mode to CompositionMode_Source:

QPainter * painter;
painter->setCompositionMode(QPainter::CompositionMode_Source);
painter->setPen(QPen{color, stroke, ...});
painter->setBrush(QBrush{...});

QPainterPath path;
path.moveTo(...);
path.lineTo(...);
...

// No alpha composition issues
painter->fillPath();
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!