1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#include "qlottiefill_p.h"
5
6QT_BEGIN_NAMESPACE
7
8QLottieFill::QLottieFill(const QLottieFill &other)
9 : QLottieShape(other)
10{
11 m_color = other.m_color;
12 m_opacity = other.m_opacity;
13}
14
15QLottieFill::QLottieFill(const QJsonObject &definition, QLottieBase *parent)
16{
17 setParent(parent);
18 QLottieBase::parse(definition);
19 if (m_hidden)
20 return;
21
22 qCDebug(lcLottieQtLottieParser) << "QLottieFill::construct():" << m_name;
23
24 QJsonObject color = definition.value(key: QLatin1String("c")).toObject();
25 m_color.construct(definition: color);
26
27 QJsonObject opacity = definition.value(key: QLatin1String("o")).toObject();
28 opacity = resolveExpression(definition: opacity);
29 m_opacity.construct(definition: opacity);
30}
31
32QLottieBase *QLottieFill::clone() const
33{
34 return new QLottieFill(*this);
35}
36
37void QLottieFill::updateProperties(int frame)
38{
39 m_color.update(frame);
40 m_opacity.update(frame);
41}
42
43void QLottieFill::render(QLottieRenderer &renderer) const
44{
45 renderer.render(fill: *this);
46}
47
48QColor QLottieFill::color() const
49{
50 QVector4D cVec = m_color.value();
51 QColor color;
52 qreal r = static_cast<qreal>(cVec.x());
53 qreal g = static_cast<qreal>(cVec.y());
54 qreal b = static_cast<qreal>(cVec.z());
55 qreal a = static_cast<qreal>(cVec.w());
56 color.setRgbF(r, g, b, a);
57 return color;
58}
59
60qreal QLottieFill::opacity() const
61{
62 return m_opacity.value();
63}
64
65QT_END_NAMESPACE
66

source code of qtlottie/src/lottie/qlottiefill.cpp