Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickcoloropacityanimation.cpp
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qquickcoloropacityanimation_p.h"
5
6
#
include
<
QtQuick
/
private
/
qquickanimation_p_p
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
10
/*!
11
\qmlmodule QtQuick.VectorImage.Helpers
12
\title Qt Quick Vector Image Helpers QML Types
13
\ingroup qmlmodules
14
\brief Provides QML types used by VectorImage and related tools.
15
\since 6.10
16
17
This module contains types used in scenes generated by \l{VectorImage}, \l{svgtoqml} and related
18
tools. The types are made to replicate specialized behavior defined by the vector graphics file
19
formats it loads and are not intended to be generally useful.
20
21
To use the types in this module, import the module with the following line:
22
23
\qml
24
import QtQuick.VectorImage.Helpers
25
\endqml
26
27
\section1 QML Types
28
*/
29
30
static
QVariant
opacityInterpolator
(
const
QColor &from,
31
const
QColor &to,
32
const
QVariant ¤t,
33
qreal progress)
34
{
35
QColor color = current.value<QColor>();
36
37
qreal fromAlpha = from.alphaF();
38
qreal toAlpha = to.alphaF();
39
40
color.setAlphaF(fromAlpha + (toAlpha - fromAlpha) * progress);
41
return
QVariant::fromValue(color);
42
}
43
44
/*!
45
\qmltype ColorOpacityAnimation
46
\inqmlmodule QtQuick.VectorImage.Helpers
47
\inherits Item
48
\brief Animates the alpha value of a color without modifying the rest of the color.
49
50
This type will animate the alpha value of a color without modifying the other components. It
51
is used to support the \c fill-opacity and \c stroke-opacity properties of SVG, which can be
52
animated separately from the opacity of the shape itself.
53
*/
54
QQuickColorOpacityAnimation::QQuickColorOpacityAnimation(QObject *parent)
55
: QQuickPropertyAnimation(parent)
56
{
57
Q_D(QQuickPropertyAnimation);
58
d->defaultToInterpolatorType =
true
;
59
d->interpolatorType = QMetaType::QColor;
60
d->extendedInterpolator =
reinterpret_cast
<QQuickPropertyAnimationPrivate::ExtendedInterpolator>(
reinterpret_cast
<
void
(*)()>(opacityInterpolator));
61
}
62
63
/*!
64
\qmlproperty real QtQuick.VectorImage.Helpers::ColorOpacityAnimation::from
65
66
The value of the color's alpha channel at the start of the animation.
67
*/
68
qreal QQuickColorOpacityAnimation::from()
const
69
{
70
Q_D(
const
QQuickPropertyAnimation);
71
return
d->from.value<QColor>().alphaF();
72
}
73
74
void
QQuickColorOpacityAnimation::setFrom(qreal from)
75
{
76
QColor color = Qt::red;
77
color.setAlphaF(from);
78
79
QQuickPropertyAnimation::setFrom(color);
80
}
81
82
/*!
83
\qmlproperty real QtQuick.VectorImage.Helpers::ColorOpacityAnimation::to
84
85
The value of the color's alpha channel at the end of the animation.
86
*/
87
qreal QQuickColorOpacityAnimation::to()
const
88
{
89
Q_D(
const
QQuickPropertyAnimation);
90
return
d->to.value<QColor>().alphaF();
91
}
92
93
void
QQuickColorOpacityAnimation::setTo(qreal to)
94
{
95
QColor color = Qt::yellow;
96
color.setAlphaF(to);
97
98
QQuickPropertyAnimation::setTo(color);
99
}
100
101
QT_END_NAMESPACE
102
103
#
include
<
moc_qquickcoloropacityanimation_p
.
cpp
>
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
opacityInterpolator
static QT_BEGIN_NAMESPACE QVariant opacityInterpolator(const QColor &from, const QColor &to, const QVariant ¤t, qreal progress)
\qmlmodule QtQuick.VectorImage.Helpers \title Qt Quick Vector Image Helpers QML Types
Definition
qquickcoloropacityanimation.cpp:30
qtdeclarative
src
quickvectorimage
helpers
qquickcoloropacityanimation.cpp
Generated on
for Qt by
1.18.0