7
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
1 |
/****************************************************************************
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
2 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
4 |
** All rights reserved.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
6 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
7 |
** This file is part of the documentation of the Qt Toolkit.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
8 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
10 |
** No Commercial Usage
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
11 |
** This file contains pre-release code and may not be distributed.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
12 |
** You may use this file in accordance with the terms and conditions
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
14 |
** this package.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
15 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
16 |
** GNU Lesser General Public License Usage
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
18 |
** General Public License version 2.1 as published by the Free Software
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
20 |
** packaging of this file. Please review the following information to
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
23 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
27 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
28 |
** If you have questions regarding the use of this file, please contact
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
29 |
** Nokia at qt-info@nokia.com.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
30 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
31 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
32 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
33 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
34 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
35 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
36 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
37 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
38 |
** $QT_END_LICENSE$
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
39 |
**
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
40 |
****************************************************************************/
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
41 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
42 |
/*!
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
43 |
\example demos/deform
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
44 |
\title Vector Deformation
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
45 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
46 |
This demo shows how to use advanced vector techniques to draw text
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
47 |
using a \c QPainterPath.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
48 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
49 |
\image deform-demo.png
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
50 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
51 |
We define a vector deformation field in the shape of a lens and apply
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
52 |
this to all points in a path. This means that what is rendered on
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
53 |
screen is not pixel manipulation, but modified vector representations of
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
54 |
the glyphs themselves. This is visible from the high quality of the
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
55 |
antialiased edges for the deformed glyphs.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
56 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
57 |
To get a fairly complex path we allow the user to type in text and
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
58 |
convert the text to paths. This is done using the
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
59 |
QPainterPath::addText() function.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
60 |
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
61 |
The lens is drawn using a single call to QPainter::drawEllipse(),
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
62 |
using a QRadialGradient to fill it with a specialized color
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
63 |
table, giving the effect of the sun's reflection and a drop
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
64 |
shadow. The lens is cached as a pixmap for better performance.
|
Eckhart Koeppen <eckhart.koppen@nokia.com>
parents:
diff
changeset
|
65 |
*/
|