1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the documentation of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:FDL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Free Documentation License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Free
19 ** Documentation License version 1.3 as published by the Free Software
20 ** Foundation and appearing in the file included in the packaging of
21 ** this file. Please review the following information to ensure
22 ** the GNU Free Documentation License version 1.3 requirements
23 ** will be met: http://www.gnu.org/copyleft/fdl.html.
26 ****************************************************************************/
29 \example painting/deform
30 \title Vector Deformation
31 \ingroup examples-painting
32 \brief Demonstrates how to manipulate the elements of a QPainterPath.
34 \brief This example shows how to use advanced vector techniques to draw text
35 using a \c QPainterPath.
37 \image deform-demo.png
39 We define a vector deformation field in the shape of a lens and apply
40 this to all points in a path. This means that what is rendered on
41 screen is not pixel manipulation, but modified vector representations of
42 the glyphs themselves. This is visible from the high quality of the
43 antialiased edges for the deformed glyphs.
45 To get a fairly complex path we allow the user to type in text and
46 convert the text to paths. This is done using the
47 QPainterPath::addText() function.
49 The lens is drawn using a single call to QPainter::drawEllipse(),
50 using a QRadialGradient to fill it with a specialized color
51 table, giving the effect of the sun's reflection and a drop
52 shadow. The lens is cached as a pixmap for better performance.