矢量变形

演示如何操作QPainterPath 的元素。

展示各种矢量变形设置的应用程序

我们定义了一个呈透镜形状的矢量变形场,并将其应用于路径上的所有点。这意味着屏幕上渲染的内容并非像素操作,而是字形本身经过修改的矢量表示。从变形后字形边缘高质量的抗锯齿效果中可以明显看出这一点。

为了生成较为复杂的路径,我们允许用户输入文本并将其转换为路径。这通过调用QPainterPath::addText()函数实现。

透镜的绘制仅需一次调用QPainter::drawEllipse(),通过QRadialGradient 使用特制的颜色表进行填充,从而呈现出阳光反射和阴影的效果。为了提升性能,透镜被作为像素图缓存。

示例项目 @ code.qt.io

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.